Ich verwende folgendes Layout in meinem Projekt.Es funktioniert gut, aber CollapsingToolbarLayout ist kollabiert, auch wenn RecyclerView leer ist oder RecyclerView hat nur sehr wenige Elemente. Das Verhalten, das ich möchte, ist, CollapsingToolbarLayout sollte nur zusammenklappen, wenn RecyclerView Elemente größer als sichtbare Elemente hat. Wie kann ich dieses Verhalten erreichen?CollapsingToolbarLayout sollte nicht zusammenklappen, wenn RecyclerView leer ist
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinator_layout"
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="wrap_content"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<include
layout="@layout/header"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
Hallo Vivart, Me zu gleiches Problem gegenüber. Wenn Sie ein Problem behoben haben, teilen Sie uns Ihre Idee mit. Dank –
habe ich auch das selbe implementiert aber leider kollabiert mein kollabierender Barlayout nicht. je. schau auf meine Frage - http://stackoverflow.com/questions/33093066/collapsing-bar-layout-and-recyclerview –