CoordinatorLayout+AppBarLayout隐藏标题栏
首先上代码
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
app:layout_scrollFlags="scroll|enterAlways"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
app:layout_scrollFlags="scroll|enterAlways"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_centerInParent="true"
android:text="我是要隐藏的顶部标题"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:text="标题"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:text="我是中间的布局"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:paddingTop="100dp"
android:id="@+id/recycle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
哪个控件要隐藏就设置app:layout_scrollFlags="scroll|enterAlways"
哪个控件滑动设置 app:layout_behavior="@string/appbar_scrolling_view_behavior"(通知布局中包含滑动组件!)
scroll: 所有想滚动出屏幕的view都需要设置这个flag- 没有设置这个flag的view将被固定在屏幕顶部。
enterAlways:这个flag让任意向下的滚动都会导致该view变为可见,启用快速“返回模式”。
enterAlwaysCollapsed:当你的视图已经设置minHeight属性又使用此标志时,你的视图只能已最小高度进入,只有当滚动视图到达顶部时才扩大到完整高度。
exitUntilCollapsed: 滚动退出屏幕,最后折叠在顶端。
更多相关文章
- android 保持屏幕唤醒状态
- Android旋转屏幕不销毁数据的方法
- 用于做 Android 屏幕自适应的文章资源
- 上接系出名门Android(8) - 控件(View)之TextSwitcher, Gallery,
- android —— 自定义控件 竖向的ViewPager,上下滑动的组件,android
- 【特效】【自定义控件】关键字飘飞效果
- 屏幕方向android:screenOrientation
- android唤醒屏幕--保持屏幕唤醒-Reprinted
- 日期选择控件