I have implemented a navigation drawer with material design as per How do I use DrawerLayout to display over the ActionBar/Toolbar and under the status bar? however because my drawer is white this causes issue with the status bar. The Google I/O 2014 application tints the status bar over the navigation drawer, how does it achieve this? I cannot find how in it's source code.
The Google IO 2014 app uses a ScrimInsetsFrameLayout to tint the status bar (and the navigation drawer will cover the status bar). I highly recommend to use it I've tried a lot and it works best! ;-)
To get the ScrimInsetsFrameLayout to work you'll need to do four things:
1.) Add the ScrimInsetsFrameLayout class to your project.
2.) Use the ScrimInsetsFrameLayout as root-element of your drawer list in the xml-file of your activity. Important: Set android:fitsSystemWindows to true for both the DrawerLayout and the ScrimInsetsFrameLayout
3.) In your activity theme (-v21) xml add the line <item name="android:statusBarColor">#android:color/transparent</item>. (Otherwise, the 'normal' status bar will overlay the status bar of the ScrimInsetsFrameLayout.)
4.) In your activity, initialize the drawer and the DrawerLayout as usual, and then call
drawerLayout.setStatusBarBackgroundColor(color) to color the status bar.
In the Google IO App, this is done in the setupNavDrawer() method of the BaseActivity
Related
New apps from Google, with Material Design, that use a Contextual Action Mode together with a Navigation Drawer.
Starting to swipe the NavigationView in, will temporary hide the ActionMode which will be re-enabled when the drawer is closed again.
In this video: navigation drawer in gmail - look at the toolbar changing because of the navigation drawer swipe.
But how to implement this behavior? The only callback from NavigationView is OnNavigationItemSelected but what we need is maybe a callback from starting to open the drawer and then finishing closing it.
Could other solutions exist, that elude me? For example:
perhaps draw a new toolbar over instead disabling the CAB?
or even is it possible to make the CAB only overlay the Toolbar but not the NavigationView (question still open here?)
I am using:
com.android.support:appcompat-v7:23.4.0
com.android.support:design:23.4.0
android.support.design.widget.NavigationView
android.support.v7.view.ActionMode
I used fragment to act as the listview in navigation drawer (as instructed by android developers guide). It's work fine to me, but now I have to put the status bar under the drawer layout - not otherwise with transparent status bar.
I have searched around and only found 1 potential solution provided in here. But it's not working. I would like to comment for more info but I dont have commentator privilege yet, so I start a new question.
In theme of your App in style.xml
add <item name="android:statusBarColor">#android:color/transparent</item>
On Lollipop, in the Gmail app, the nav drawer opens up behind the top status bar. My nav drawer layout is match_parent, but it stops below the status bar. Any idea how to accomplish this?
FYI I am using the new Toolbar...
Got this image off the internet, don't mind the image on the right..
Please see this answer:
https://stackoverflow.com/a/26440880/961759
Here's a nice open source example on how to accomplish the desired behaviour
https://github.com/kanytu/android-material-drawer-template
I want to make to cover action bar when navigation drawer appears.
but i know only to stay action bar when navigation drawer appears.(and i know that this is standard form at google)
i didn’t find stackoverflow perfectly, because I cannot speak english well.
Now i made (picture 1)form, How do i want to make to cover action bar when navigation drawer appears as (pic2) form?
pic 1 : https://imageshack.com/i/ex3qfeOIp
pic 2: https://imageshack.com/i/p88OOwyTp
Its kind of easy.First u need to add listener to your navigation drawer setDrawerListener in that u make a listener of DrawerListener class. This class has methods onDrawerClosed() and onDrawerOpened(). In these methods u can hide the action bar or choose to show the action bar appropriately using getActionBar().hide() or getActionBar().show()
Since Android 4.4 was introduced I had this big question about translucent notification and navigation bar:
How do you make a custom theme so that the notification bar is the same color as the action bar as well as the navigation bar be the same color that the current activity is?
A good example of this is the Trello app:
And:
Even if you open a navigation drawer, the navigation bar still retains its color. How does one achieve this?
You can use the new (as of 4.4) Theme.Holo.NoActionBar.TranslucentDecor or Theme.Holo.Light.NoActionBar.TranslucentDecor themes. Or you can set windowTranslucentNavigation in your theme. You'll also want to fill the area behind the system bars by setting fitsSystemWindows to true in your layout.
More info in the Android 4.4 APIs changes document