CollapsingToolbarLayout may have a Toolbar collapse bug in Material1.5.0 and 1.6.0alpha3
See original GitHub issueDescription: Full description of issue here Collapsible Image toolbars may collapsible in Material1.5.0 and 1.6.0 Alpha3 when collapsible image toolbars are made using CollapsingToolbarLayout and the MaterialToolbar However, it is perfectly fine when using the MaterialComponents topic (only the topic configuration has been modified; the rest of the code has not been adjusted).
Expected behavior: Screenshots and/or description of expected behavior Toolbar normal fold
Source code: The code snippet which is causing this issue
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.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:background="@color/white"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar_scrolling"
android:layout_width="match_parent"
android:layout_height="250dp"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:expandedTitleTextColor="@color/white"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:src="@drawable/img"
android:id="@+id/image_scrolling_top"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="fitXY"
app:layout_collapseMode="parallax" />
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_scrolling"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:src="@drawable/ic_baseline_add_24"
app:layout_anchor="@id/app_bar_scrolling"
app:layout_anchorGravity="bottom|end" />
<include layout="@layout/content_scrolling" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Minimal sample app repro: Please consider attaching a minimal sample app that reproduces the issue. This will help narrow down the conditions required for reproducing the issue, and it will speed up the bug fix process. You may attach a zip file of the sample app or link to a GitHub repo that contains the sample app.
Android API version: Android API version here android10 and android12
Material Library version: Material Android Library version you are using here (e.g., 1.1.0-alpha07) 1.5.0 and 1.6.0alpha3
Device: Device on which the bug was encountered here Xiaomi9 and Android Virtual Devices
To help us triage faster, please check to make sure you are using the latest version of the library. sure!
We also happily accept pull requests. ok
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (1 by maintainers)
Top GitHub Comments
I had exactly the same problem. Thanks to the comments here I was able to solve it for myself in the following XML-only way:
styles.xml:
themes.xml:
Tested for version
1.7.0
Thanks.