Android实现滑动悬浮置顶(一)采用Material Design新控件实现
来源:互联网 发布:淘宝积分在哪里看到 编辑:程序博客网 时间:2024/06/09 19:22
我们直接来看布局
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/top_left" android:layout_width="match_parent" android:layout_height="match_parent" android:clipToPadding="true" android:fitsSystemWindows="true" android:orientation="vertical"> <include layout="@layout/main_search" /> <android.support.design.widget.CoordinatorLayout android:id="@+id/layoutContentd" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/main_search" android:visibility="visible"> <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#00000000" android:fitsSystemWindows="true" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <!-- app:layout_scrollFlags="scroll|exitUntilCollapsed|snap"--> <!--<android.support.design.widget.CollapsingToolbarLayout--> <!--android:id="@+id/collapsingToolbar"--> <!--android:layout_width="match_parent"--> <!--android:layout_height="wrap_content"--> <!--app:layout_behavior="@string/appbar_scrolling_view_behavior"--> <!--app:contentScrim="#00000000"--> <!--app:layout_scrollFlags="scroll|exitUntilCollapsed"--> <!--app:statusBarScrim="#00000000">--> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#ffffff" android:orientation="vertical" app:layout_behavior="@string/appbar_scrolling_view_behavior" app:layout_scrollFlags="scroll"> <com.youth.banner.Banner android:id="@+id/banner" android:layout_width="match_parent" android:layout_height="350px" /> <include layout="@layout/mian_top_item" /> </LinearLayout><!--</android.support.design.widget.CollapsingToolbarLayout>--> <!--悬浮的部分--> <LinearLayout android:id="@+id/layTabs" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#FFE4C4" android:orientation="horizontal" android:padding="10dp"> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:text="tab1" android:textColor="#333333" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:text="tab2" android:textColor="#333333" /> </LinearLayout> </android.support.design.widget.AppBarLayout> <!--主内容--> <android.support.v4.widget.NestedScrollView android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp" android:gravity="center" android:text="@string/text" /> </android.support.v4.widget.NestedScrollView> </android.support.design.widget.CoordinatorLayout></RelativeLayout>来看下效果图
注意:
CoordinatorLayout 实现了多种Material Design中提到的滚动效果
响应滚动事件AppBarLayout必须是CoordinatorLayout的直接子View,然后我们需要定义AppBarLayout与滚动视图之间的联系,在任意支持嵌套滚动的view上添加app:layout_behavior,AppBarLayout里面定义的view只要设置了app:layout_scrollFlags属性,必须至少启用scroll这个flag,这样这个view才会滚动出屏幕
源码地址
阅读全文
0 0
- Android实现滑动悬浮置顶(一)采用Material Design新控件实现
- Android实现滑动悬浮置顶(二)采用改写Scroview实现
- Android 滑动悬浮置顶效果的新实现
- Android实现滑动悬浮置顶效果
- Android实现Material Design风格的设置页面(滑动开关控件)
- Android Material Design新UI控件使用大全 一
- Android Material Design新UI控件使用大全 一
- Android Material Design新UI控件使用大全 一
- Android Material Design新UI控件使用大全 一
- Android Material Design新UI控件使用大全 一
- Android Material design 中的新控件使用
- Android Material Design 动画实现
- Android Material Design 动画实现
- android 实现悬浮控件
- android 实现悬浮控件
- Android ScrollView向上滑动控件顶部悬浮效果实现
- Android ScrollView向上滑动控件顶部悬浮效果实现
- Android ScrollView向上滑动控件顶部悬浮效果实现
- “中国造”品牌正在崛起,实体经济继续朝前奔跑
- Android实战(橘子娱乐)-首页(第六篇 Presenter如何将Model层数据传递给View层)
- [openjudge]百练2755 神奇的口袋
- jQuery商品精简、全部显示的实现
- 数値のみ入力可能
- Android实现滑动悬浮置顶(一)采用Material Design新控件实现
- VI命令大全
- ajax 参数详解
- Linux服务器批量管理工具
- 简单几行命令跑通YOLO示例(目标检测)
- 【SpringMVC学习05】SpringMVC中的参数绑定总结
- diamond原理图sch文件中画输入输出管脚
- IntelliJ IDEA 快捷键和设置
- mac 下包管理工具 brew