Skip to content

[CollapsingToolbarLayout] White Flash During Collapse Animation #4976

@royaff0

Description

@royaff0

Description: When a CollapsingToolbarLayout collapses, a brief white flash is visible. This flicker appears to be synchronized with the scrimAnimationDuration. It occurs just before the contentScrim and statusBarScrim colors are fully shown.

Screen_Recording_20251119_232857_testdemo.mp4

Expected behavior: The contentScrim and statusBarScrim should fade in smoothly

Source code:

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/black"
    tools:context=".MainActivity">

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/appbar_layout"
        android:layout_width="match_parent"
        android:fitsSystemWindows="true"
        android:background="#000000"
        android:layout_height="wrap_content">

        <com.google.android.material.appbar.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:fitsSystemWindows="true"
            app:contentScrim="#330000"
            app:statusBarScrim="#330000"
            app:scrimAnimationDuration="2000"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <androidx.appcompat.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="88dp"
                android:layout_gravity="bottom"
                app:contentInsetStart="0dp"
                app:contentInsetEnd="0dp"
                app:layout_scrollFlags="scroll"
                app:layout_collapseMode="pin">

            </androidx.appcompat.widget.Toolbar>

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="200dp">

            </FrameLayout>

        </com.google.android.material.appbar.CollapsingToolbarLayout>

    </com.google.android.material.appbar.AppBarLayout>

    <androidx.core.widget.NestedScrollView
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#200000">

        <LinearLayout
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="800dp"/>

    </androidx.core.widget.NestedScrollView>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

Minimal sample app repro:
demo.zip

Android API version: 36
Material Library version: 1.13.0
Device: Any

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions