You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
I am setting android:windowTranslucentStatus to true to achieve a transparent status bar to blend with the ImageView of a CollapsingToolbar when expanded and it follows android:statusBarColor when collapsed in FragmentA. However when navigating to FragmentB that only has MaterialToolbar the status bar color change and does not follow android:statusBarColor of the base theme.
Expected behavior:
If I set statusBarForeground at the Theme.App.NoActionBar.TranslucentStatusBar then there will be no translucency of status bar on both destinations, I want both behaviors.
Translucent status bar when CollapsingToolbar is expanded and colored status bar when collapsed on FragmentA.
Controlled color on status bar for FragmentB, not a variant color of the default background of MaterialToolbar. I noticed that it is using a light version of the default background color of MaterialToolbar shown in the right image which is pinkish.
So far I cannot achieve the second requirement.
Source code:
Toolbars theme set
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Toolbar style on both light and night mode -->
<style name="AppToolbar" parent="Widget.Material3.Toolbar.Surface" tools:keep="@style/AppToolbar">
<item name="contentInsetStart">0dp</item>
<item name="contentInsetEnd">0dp</item>
<item name="contentInsetStartWithNavigation">0dp</item>
<item name="materialThemeOverlay">@style/ThemeOverlay.App.Toolbar</item>
</style>
<style name="ThemeOverlay.App.Toolbar" parent="" tools:keep="@style/ThemeOverlay_App_Toolbar">
<!-- Background color -->
<item name="colorSurface">@color/colorWhite_Primary</item>
<!-- Title and Navigation icon color -->
<item name="colorOnSurface">@color/colorPrimaryDark_White</item>
<!-- Subtitle and Action item color -->
<item name="colorOnSurfaceVariant">@color/colorPrimaryDark_White</item>
<!-- Action item and Overflow menu color when `colorOnSurfaceVariant` is not working -->
<!-- Drawer icon and Navigation icon also use this -->
<item name="colorControlNormal">@color/colorPrimaryDark_White</item>
</style>
<!-- CollapsingToolbar style on both light and night mode -->
<style name="AppCollapsingToolbar" parent="Widget.Material3.CollapsingToolbar" tools:keep="@style/AppCollapsingToolbar">
<item name="titleCollapseMode">scale</item>
<item name="scrimAnimationDuration">700</item>
<!-- Collapsed Toolbar background -->
<item name="contentScrim">?attr/colorPrimary</item>
<item name="expandedTitleTextColor">@android:color/white</item>
<item name="collapsedTitleTextColor">@color/colorPrimaryDark_White</item>
<item name="statusBarScrim">@color/colorGray_PrimaryDark</item>
<item name="collapsedTitleTextAppearance">@style/TextAppearance.App.CollapsingToolbar.Collapsed</item>
<item name="expandedTitleTextAppearance">@style/TextAppearance.App.CollapsingToolbar.Expanded</item>>
</style>
<style name="TextAppearance.App.CollapsingToolbar.Expanded" parent="TextAppearance.Material3.HeadlineSmall" tools:keep="@style/TextAppearance_App_CollapsingToolbar_Expanded">
<item name="android:shadowRadius">4</item>
<item name="android:shadowDy">1</item>
<item name="android:shadowColor">@android:color/black</item>
</style>
<style name="TextAppearance.App.CollapsingToolbar.Collapsed" parent="TextAppearance.Material3.TitleLarge" tools:keep="@style/TextAppearance_App_CollapsingToolbar_Collapsed">
<!-- no-op -->
</style>
<!-- ActionBar -->
<!-- Used by some external module like Firebase UI Auth or OSS License Android -->
<style name="AppActionBar" parent="" tools:keep="@style/AppActionBar">
<!-- Background color -->
<item name="colorSurface">@color/colorWhite_Primary</item>
<!-- Title and Navigation icon color -->
<item name="colorOnSurface">@color/colorPrimaryDark_White</item>
<!-- Subtitle and Action item color -->
<item name="colorOnSurfaceVariant">@color/colorPrimaryDark_White</item>
<!-- Action item and Overflow menu color when `colorOnSurfaceVariant` is not working -->
<!-- Drawer icon and Navigation icon also use this -->
<item name="colorControlNormal">@color/colorPrimaryDark_White</item>
</style>
</resources>
App's base theme
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme -->
<style name="Theme.App" parent="Theme.Material3.DayNight">
<!-- Primary brand color -->
<item name="colorPrimary">@android:color/white</item>
<item name="toolbarStyle">@style/AppToolbar</item>
<item name="actionBarSize">@dimen/AppTopBarSize</item>
<item name="collapsingToolbarLayoutStyle">@style/AppCollapsingToolbar</item>
<!-- Status bar color -->
<item name="android:statusBarColor">@android:color/darker_gray</item>
<item name="android:forceDarkAllowed" tools:targetApi="q">false</item>
</style>
<!-- Activity with disabled ActionBar -->
<style name="Theme.App.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<!-- Activity theme for CollapsingToolbarLayout -->
<style name="Theme.App.NoActionBar.TranslucentStatusBar">
<item name="android:windowTranslucentStatus">true</item>
</style>
</resources>
ArcherEmiya05
changed the title
Status Bar color not consistent between Fragment with CollapsingToolbar and only MaterialToolbar
Status Bar color not consistent between Fragments with CollapsingToolbar and only MaterialToolbar
Oct 2, 2024
Description:
I am setting
android:windowTranslucentStatus
to true to achieve a transparent status bar to blend with the ImageView of a CollapsingToolbar when expanded and it followsandroid:statusBarColor
when collapsed in FragmentA. However when navigating to FragmentB that only has MaterialToolbar the status bar color change and does not followandroid:statusBarColor
of the base theme.Expected behavior:
If I set
statusBarForeground
at theTheme.App.NoActionBar.TranslucentStatusBar
then there will be no translucency of status bar on both destinations, I want both behaviors.So far I cannot achieve the second requirement.
Source code:
Toolbars theme set
App's base theme
Manifest
FragmentA
FragmentB
Android API version: 5.0
Material Library version: 1.12.0
Device: Pixel (Emulator)
The text was updated successfully, but these errors were encountered: