Andy
Andy

Reputation: 331

Android: status bar not theme on transitiong to new activity

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>

Upvotes: 10

Views: 3142

Answers (4)

Bijoyan Das
Bijoyan Das

Reputation: 1

In values-v21/styles.xml, change

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

to

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

Upvotes: 0

kasyauqi
kasyauqi

Reputation: 645

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.

Upvotes: 1

Pyrmont
Pyrmont

Reputation: 256

Change

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

to

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

Upvotes: 8

Shivputra N
Shivputra N

Reputation: 688

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

Upvotes: 1

Related Questions