Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>
like image 275
Andy Avatar asked Jun 18 '15 06:06

Andy


2 Answers

Change

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

to

<item name="android:statusBarColor">@color/PrimaryDarkColor</item>
like image 76
Pyrmont Avatar answered Oct 14 '22 11:10

Pyrmont


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

like image 37
Shivputra N Avatar answered Oct 14 '22 10:10

Shivputra N