【发布时间】:2017-01-07 14:55:16
【问题描述】:
我正在尝试在我的应用程序中使用协调器布局来完成滚动行为。
我有以下活动的布局结构。
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.Dark.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.Dark.PopupOverlay"/>
</android.support.design.widget.AppBarLayout>
<!-- The layout to be collapse with toolbar -->
<LinearLayout
android:id="@+id/ll_collapse_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
当我向上滚动回收站视图项时,工具栏会折叠并向上移出窗口,而当我向下滚动时,工具栏又会返回。
当我滚动 Recycler View 时,是否可以折叠带有工具栏的 LinearLayout?
【问题讨论】:
标签: android android-layout android-recyclerview toolbar android-collapsingtoolbarlayout