Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Material style navigation drawer, statusbar color gets too dark

I am trying to follow the Material Design guidelines to make an app with an actionbar(toolbar) and a navigation drawer, so that it would look like in Google Apps. The solution I have found is to set "android:windowTranslucentStatus" to true in my theme , as well as keeping "android:fitsSystemWindows" as false , compensating for it with extra padding on my toolbar.

The problem is though, that the final color of the statusbar is too dark. Even if I set the toolbar to the same material color as the G-mail app for example, the statusbar color is darker in my app than in the G-Mail app.

Could somebody please point me in the right direction here? I've heard a lot about some custom ScrimLayout hack , but I would like to stick to Android APIs if possible.

like image 249
Near Avatar asked Nov 10 '22 16:11

Near


1 Answers

I don't know for which api level you're trying this, but for api>=21 try this:

In your values-v21/styles.xml do the following:

   <style name="AppTheme" parent="android:Theme.Material.Light.DarkActionBar">

    <item name="android:colorPrimary">@color/toolbarcolor</item>
    <item name="android:colorPrimaryDark">@color/navdrawercolor</item>

   </style>

sources: Youtube - AndroidDeveloper / from Holo to Material

Edit:

for setting the status bar color in api >=21 you could use:

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

and set the fullscreen mode in your onCreate in your activity:

            getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                    | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
like image 102
Johannes Avatar answered Nov 15 '22 13:11

Johannes