question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CollapsingToolbarLayout may have a Toolbar collapse bug in Material1.5.0 and 1.6.0alpha3

See original GitHub issue

Description: 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 normal error

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:closed
  • Created 2 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
HendrikVEcommented, Nov 19, 2022

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:

<style name="Widget.App.CollapsingToolbar" parent="Widget.Material3.CollapsingToolbar">
    <item name="forceApplySystemWindowInsetTop">false</item>
</style>

themes.xml:

<style name="AppTheme.Light" parent="Theme.Material3.Light.NoActionBar">
    <item name="collapsingToolbarLayoutStyle">@style/Widget.App.CollapsingToolbar</item>
    < ... />
</style>

Tested for version 1.7.0

0reactions
XuanRanDevcommented, Nov 20, 2022

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:

<style name="Widget.App.CollapsingToolbar" parent="Widget.Material3.CollapsingToolbar">
    <item name="forceApplySystemWindowInsetTop">false</item>
</style>

themes.xml:

<style name="AppTheme.Light" parent="Theme.Material3.Light.NoActionBar">
    <item name="collapsingToolbarLayoutStyle">@style/Widget.App.CollapsingToolbar</item>
    < ... />
</style>

Tested for version 1.7.0

Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CollapsingToolbarLayout not working properly - Stack Overflow
The problem is that when the toolbar is expanded, the icons are way too high. And when collapsed, they are simply gone. See...
Read more >
CollapsingToolbarLayout - Android Developers
CollapsingToolbarLayout is a wrapper for Toolbar which implements a collapsing app bar. It is designed to be used as a direct child of...
Read more >
Using CollapsingToolbarLayout with navigation [110887183]
I'm not quite sure this is a bug but I'm having trouble using Navigation UI component with both standard Toolbar and CollapsingToolbarLayout.
Read more >
How to Collapse Toolbar Layout in Android? - GeeksforGeeks
CollapsingToolbarLayout gives the facility of adjusting the size of toolbar title text when it is expanded or contracted. A sample GIF is given ......
Read more >
Modular and customizable Material Design UI components for ...
Our design team follow the iOS catalog app , the hint text of TextInputLayout is vertically center, but when I try Android it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found