[CollapsingToolbarLayout] DarkTheme wrong toolbar background color
See original GitHub issueDescription: I have CollapsingToolbarLayout with a toolbar that is always pinned to top and a collapsible view. The toolbar’s background color based on the toolbar elevation in dark mode is not applied, before collapsing and after collapsing.
Before collapsing:
After collapsing:
Expected behavior: Toolbar’s background to be lighter than the background based on it’s elevation
Source code:
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:titleEnabled="false"
app:contentScrim="?attr/colorSurface"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
<View
android:layout_width="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:background="@android:color/holo_orange_dark" />
<androidx.appcompat.widget.Toolbar
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>
Android API version: 28
Material Library version: 1.1.0-alpha010
Device: Android Emulator
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:14 (8 by maintainers)
Top Results From Across the Web
Collapsing toolbar changes color in night mode - Stack Overflow
MaterialComponents as a parent for dark theme. For some reason it uses colorOnSurface for toolbar color instead of colorPrimary.
Read more >How to Collapse Toolbar Layout in Android? - GeeksforGeeks
I am using Dark theme for AppBarLayout. Inside this AppBarLayout i. have used CollapsingToolbarLayout. -->. < ...
Read more >Collapsing Toolbar with Image - Android Studio Tutorial
In this tutorial, we will learn how to implement a collapsing toolbar with an expandable image into our Android app.
Read more >App bars: top - Material Design
When a top app bar transforms into a contextual action bar, the following changes occur: The bar color changes; Navigation icon is replaced...
Read more >MaterialToolbar - Android Developers
Regarding the Dark Theme elevation overlays, it's important to note ... While a MaterialToolbar with a transparent background can be used ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It looks like we should check to see if we can apply the elevation overlay color to the content scrim.
Maybe it’s late but I solve my problem with first check is dark mode active by using this method
then setting the
collapsingToolbarLayout.setContentScrimColor
to elevation overlayed color like this