Navigation View combined with Contextual Action Mode? - android

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

Related

How can I open a navigation drawer with a swipe from the left gesture?

I created a navigation drawer but I don't want to use the ActionBar with the hamburger button, I would like to be able to open the navigation drawer with a swiping gesture from the left to the right in every activity.
I also don't understand very well the use of Fragments.
By the way, to create my Navigation drawer I used this youtube video: Video
Thanks.
You can achieve this by hiding the hamburger button. Set your toolbar navigation icon to null.
toolbar.setNavigationIcon(null);

How to implement navigation drawer button ( hamburger ) which animates to back button when drawer open

I have been looking to find this for quite some time but couldn't find any solution.
I want to implement this kind of button which looks like a hamburger navigation drawer button when drawer is closed.But when it is opened the icon animates and convert to a 'back button' as show in the image.
That is the ActionBarDrawerToggle. The official implementation is in the appcompat-v7 library, and it requires that you be using AppCompatActivity and all its trimmings (e.g., Theme.AppCompat or children).
If you are using the native action bar, given some time, you can cross-port the ActionBarDrawerToggle from source to work with the native action bar. It took me an hour or two, IIRC.

Alternative for ActionBarDrawerToggle

I'm creating an application which got both an ActionBar and a navigation drawer. I need a way to change the indicator of the action bar at some cases to have an up button (the arrow sign) instead of the 3 navigational drawer dots.
When trying to use ActionBarDrawerToggle I had many issues. I first used the v4 type which changed the appearence of the indicator but without changing the functionality (pressing the arrow button opened the drawer instead of going up the backstack). I tried using the v7 type but then this happened:
stackoverflow.com/questions/30591464/updating-v7-support-jar-causes-class-not-found-exception
So is there a way to acheive what I need via other ways?

Dark tinted status bar over navigation drawer

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

Navigation Drawer with Up navigation in ActionBar

Does anyone successfully implemented Navigation Drawer with Fragments, Up Navigation and ActionBar?
As stated in documentation Up Navigation works automatically with Activities. But If I want to implement Navigation Drawer, then I have to use fragments.
I have set:
ActionBar actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
I also put all fragments to BackStack. When checking listener OnBackStackChangeListener, I see that BackStack is being checked, but the Up navigation arrow doesn't show up.
Navigation Drawer with Fragments
take a look at this question and this may also help you. As stated in the second link, you don't "have to use Fragments to use the NavigationDrawer"
Although many navigation drawer examples show how fragments can be
used with the navigation drawer, you can also use a
RelativeLayout/LinearLayout if you wish to use the drawer as an
overlay to your currently displayed Activity.
This is actually the approach I've used in one of my recent projects and it works fine.

Categories

Resources