<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_video_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="exle.li_yuweii.superapp.activitys.VideoDetailActivity">
<android.support.design.widget.AppBarLayout
android:fitsSystemWindows="true"
android:id="@+id/video_detail_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffff"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:fitsSystemWindows="true"
android:id="@+id/video_detail_collapsing"
android:layout_width="match_parent"
android:layout_height="200dp"
app:contentScrim="#FB7299"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
>
<FrameLayout
android:id="@+id/video_detail_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<SurfaceView
android:id="@+id/video_detail_surface_view"
android:layout_width="match_parent"
android:layout_height="200dp"
android:visibility="invisible" />
<LinearLayout
android:id="@+id/video_detail_play_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#9999"
android:gravity="center_vertical"
android:orientation="horizontal"
android:visibility="invisible">
<ImageView
android:id="@+id/video_controller_play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_media_pause" />
<SeekBar
android:id="@+id/video_controller_progress"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="@+id/video_controller_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="00:00" />
<ImageView
android:id="@+id/video_controller_orientation_switch"
android:layout_width="20dp"
android:layout_height="20dp"
android:paddingLeft="3dp"
android:src="@drawable/change" />
LinearLayout>
FrameLayout>
<ImageView
android:fitsSystemWindows="true"
android:id="@+id/video_detail_cover"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitXY" />
<android.support.v7.widget.Toolbar
android:id="@+id/video_detail_tool_bar"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
app:layout_collapseMode="pin">
<ImageView
android:id="@+id/video_detail_iamge1"
android:src="@drawable/action_button_back_pressed_light"
android:layout_width="wrap_content"
android:layout_height="22dp" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/video_detail_text1"
android:text="SuperApp"
android:gravity="center"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/video_detail_image"
android:src="@drawable/ic_tv_play"
android:adjustViewBounds="true"
android:visibility="invisible"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:layout_height="22dp" />
<TextView
android:id="@+id/video_detail_text"
android:visibility="invisible"
android:text="立即播放"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
LinearLayout>
android.support.v7.widget.Toolbar>
android.support.design.widget.CollapsingToolbarLayout>
android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/video_detail_play_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="16dp"
app:layout_anchor="@id/video_detail_appbar"
app:layout_anchorGravity="right|bottom" />
<LinearLayout
android:id="@+id/video_detail_linear_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.design.widget.TabLayout
android:id="@+id/video_detail_tab_layout"
android:layout_width="150dp"
android:layout_height="wrap_content"
app:tabSelectedTextColor="@color/topColor"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_gravity="bottom"
app:tabTextColor="#000"/>
<android.support.v4.view.ViewPager
android:id="@+id/video_detail_view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never" />
LinearLayout>
android.support.design.widget.CoordinatorLayout>
app:layout_scrollFlags="scroll|exitUntilCollapsed"
这个设置推到上边toolbar在上边保留
android:fitsSystemWindows="true"
这个设置沉浸效果设置顶部状态栏时
app:layout_anchor="@id/video_detail_appbar"
FloatingActionButton必须绑定到AppBar上才可以推上去消失
app:layout_behavior="@string/appbar_scrolling_view_behavior"
AppBar下方的控件要设置这个属性才可以联动
//设置不可推动
layoutParams = (AppBarLayout.LayoutParams) collapsing.getLayoutParams();
int scrollFlags = layoutParams.getScrollFlags();
layoutParams.setScrollFlags(0);
//设置可以推动
layoutParams = (AppBarLayout.LayoutParams) collapsing.getLayoutParams();
layoutParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL
| AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
collapsing.setLayoutParams(layoutParams);//这句必须加上