Я хочу добавить поддержку прокрутки к более чем одному прокручиваемому дочернему виду CoordinatorLayout
в сочетании с AppBarLayout
и CollapsingToolbarLayout
. При прокрутке RecyclerView
или AppBarLayout
(сжатый код ниже) панель приложения и его содержимое успешно прокручиваются и сворачиваются. Однако при попытке инициировать событие прокрутки на LinearLayout
выше RecyclerView
ничего не происходит, потому что LinearLayout
не знает, чтобы прокручивать или сворачивать представление.
Цель состоит в том, чтобы LinearLayout
действовать как липкий заголовок RecyclerView
и нижний колонтитул в AppBarLayout
и получать такое же поведение прокрутки, как RecyclerView
, похожее на Spotify shuffle play/available offline header. На самом деле было бы здорово, если бы appbar_scrolling_view_behavior
layout_behavior
можно было применить к LinearLayout
аналогично RecyclerView
, но я полагаю, что поведение игнорируется в прокручиваемых представлениях. Кто-нибудь знает об обходном пути для этого, который не требует реализации представления LinearLayout
как строки в RecyclerView
?
<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:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="@dimen/collapsible_app_bar_height"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/gradient_banner"
app:contentScrim="@color/background_content_frame"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="@+id/image_header"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/some_image"
app:layout_collapseMode="parallax"/>
<android.support.v7.widget.Toolbar
android:id="@+id/collapsible_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:layout_collapseMode="pin"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/slide_handle_height"
android:orientation="horizontal"
android:background="@color/slide_handle"
android:gravity="center_vertical">
<!-- three buttons -->
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/slide_handle_height"
android:scrollbars="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>