Android: status bar not theme on transitiong to new activity

3.1k views Asked by At

I have create a simple app with 2 activities. Main (launcher) activity is themed properly where colorPrimaryDark is applied to status bar. But when I transition to new activity, everything seems normal except status bar. It somehow colored white. Any idea why this could be happening?

Running this on OnePlus One (Lollipop 5.0.2)

Target api -> 16+

enter image description here

values/styles.xml

<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/PrimaryColor</item>
    <item name="colorPrimaryDark">@color/PrimaryDarkColor</item>
    <item name="colorAccent">@color/accent</item>
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
</style>

values-v21/styles.xml

<style name="AppTheme" parent="AppTheme.Base">
    <item name="android:windowContentTransitions">true</item>
    <item name="android:windowAllowEnterTransitionOverlap">true</item>
    <item name="android:windowAllowReturnTransitionOverlap">true</item>
    <item name="android:windowSharedElementEnterTransition">@android:transition/slide_bottom</item>
    <item name="android:windowSharedElementExitTransition">@android:transition/move</item>
    <item name="android:windowDrawsSystemBarBackgrounds">true</item>
    <item name="android:statusBarColor">@android:color/transparent</item>
</style>

layout/activity_settings.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/content"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#856"
    android:fitsSystemWindows="true"
    android:orientation="vertical"
    tools:context=".SettingsActivity">

    <include layout="@layout/toolbar" />

</LinearLayout>

4

There are 4 answers

4
Pyrmont On BEST ANSWER

Change

<item name="android:statusBarColor">@android:color/transparent</item>

to

<item name="android:statusBarColor">@color/PrimaryDarkColor</item>
0
Shivputra N On

Change the api level to 11+, you can find it. change the Theme to DarkActionBar

0
Bijoyan Das On

In values-v21/styles.xml, change

<item name="android:statusBarColor">@android:color/transparent</item>

to

<item name="android:statusBarColor">@color/colorPrimaryDark</item>
0
kasyauqi On

You might be not needing this anymore but I recently get this issue so maybe this will help others.

I fix it by creating new style in values-v21/styles.xml extending from the AppTheme:

<style name="AppTheme.SolidStatusBar">
    <item name="android:statusBarColor">@color/PrimaryDarkColor</item>
</style>

and use this as your new Activity theme in manifest. This way your changes don't have to interfere with activities that need to use translucent status bar like your Main activity.

I have no idea why is this happening though.