kike
kike

Reputation: 4463

Grey status bar

When I run my app, the Status Bar is greyed out without any icons.

This is how it should be shown: first image

and this is how it appears: second image (please, drag the image to notice the Status Bar)

I'm using Theme.AppCompat.Light.NoActionBar

Any ideas?

EDIT: This is my AppTheme:

<!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowContentOverlay">@null</item>
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/background_grey</item>
        <item name="android:textColorPrimary">@color/black_effective</item>
        <item name="android:textColor">@color/black_effective</item>
        <item name="android:textColorHint">@color/text_grey</item>
        <item name="android:windowBackground">@color/bg_color</item>
        <item name="android:textAllCaps">false</item>
        <item name="android:textSize">16sp</item>
        <item name="android:typeface">sans</item>
        <item name="drawerArrowStyle">@style/MaterialDrawer.DrawerArrowStyle</item>
        <item name="android:textAppearance">@style/TextAppearance.Text.Regular</item>
        <item name="android:homeAsUpIndicator">@drawable/ic_arrow_back_white_24px</item>
    </style>

Upvotes: 1

Views: 2195

Answers (3)

kike
kike

Reputation: 4463

Despite @Leonardo-cavazzani 's answer would work for most cases. In my case I could show the status bar icons by removing this line of code:

<item name="android:windowContentOverlay">@null</item>

Upvotes: 0

Leonardo Cavazzani
Leonardo Cavazzani

Reputation: 293

You can create a new Theme for your app and change the color in values/styles.xml

<resources>
 <!-- Base application theme. -->
 <style name="AppTheme" parent="Theme.AppCompat.Light">
    <item name="colorPrimary">@color/color_primary</item>
    <item name="colorPrimaryDark">@color/color_secondary</item>
    <item name="colorAccent">@color/color_accent</item>
    <item name="android:statusBarColor">@color/color_primary</item>
 </style>
</resources>

Keep in mind this image when you want to put the right color in the right place:

enter image description here

Check this quastion here How to change the status bar color in android It may help you a lot

Upvotes: 2

Clement Osei Tano
Clement Osei Tano

Reputation: 832

This is one way to set your statusbar color after manually changing/setting actionbar. NOTE: I have tested this on API 23 only:

ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDefaultDisplayHomeAsUpEnabled(true);
        Window window = getWindow();
        if (Build.VERSION.SDK_INT >= 21) {
            actionBar.setElevation(0);
        }

                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            window.setStatusBarColor(getResources().getColor(R.color.colorPrimaryDark));
        }

    }

Upvotes: 2

Related Questions