Dark tinted status bar above the navigation drawer

I have implemented a Material Design Navigation Drawer according to How do I use DrawerLayout to display above the action / toolbar and below the status bar? however since my box is white this causes a status bar issue. Google I / O 2014 app displays status bar in nav drawer, how is this achieved? I can't find how the source code is in it.

+3


source to share


1 answer


Google IO 2014 app uses ScrimInsetsFrameLayout to display the status bar (and the navigation drawer will cover the status bar). I highly recommend using it, I've tried a lot and it works the best !; -)

To get ScrimInsetsFrameLayout to work, you need to do four things:

1.) Add the class ScrimInsetsFrameLayout

to your project.

2.) Use ScrimInsetsFrameLayout as the root element of your box list in your activity xml file. Important: set android:fitsSystemWindows

in true

for both DrawerLayout

andScrimInsetsFrameLayout



3.) In your activity theme (-v21) xml add the line <item name="android:statusBarColor">@android:color/transparent</item>

. (Otherwise, the "normal" status bar will overlap the ScrimInsetsFrameLayout status bar.)

4.) In your activity, initialize the box and DrawerLayout

as usual and then call drawerLayout.setStatusBarBackgroundColor(color)

to color the status bar.

In google IO app this is done in BaseActivity methodsetupNavDrawer()

+2


source







All Articles