滑动栏效果
1 <?xml version="1.0" encoding="utf-8"?> 2 <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:app="http://schemas.android.com/apk/res-auto" 4 android:layout_width="match_parent" 5 android:layout_height="match_parent" 6 > 7 8 <android.support.design.widget.AppBarLayout 9 android:layout_width="match_parent" 10 android:layout_height="200dp"> 11 12 <android.support.design.widget.CollapsingToolbarLayout 13 android:layout_width="match_parent" 14 android:layout_height="match_parent" 15 android:theme="@style/Theme.AppCompat.DayNight.DarkActionBar" 16 app:layout_scrollFlags="scroll|exitUntilCollapsed" 17 android:background="@android:color/white"> 18 <!-- 。。。顶部布局。。。--> 19 20 </android.support.design.widget.CollapsingToolbarLayout> 21 22 </android.support.design.widget.AppBarLayout> 23 24 <!-- 25 android:fillViewport="true" 26 在ScrollView中嵌套 viewpager 27 必须设置android:fillViewport="true" 28 --> 29 30 <android.support.v4.widget.NestedScrollView 31 android:layout_width="match_parent" 32 android:layout_height="match_parent" 33 android:fillViewport="true" 34 app:layout_behavior="@string/appbar_scrolling_view_behavior"> 35 <!-- 。。。底部布局。。。--> 36 <!--只能有一个直接子布局--> 37 38 </android.support.v4.widget.NestedScrollView> 39 </android.support.design.widget.CoordinatorLayout>