Alternative for ActionBarDrawerToggle - android

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?

Related

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.

How to increase the width of pulling the Navigation Drawer from the side

Is there an API to increase the width/sensitivity of pulling the Navigation Drawer from the left side of the screen? For ex: as of now, I need to press my finger closely to the left of the screen to pull the drawer out. I would like to increase this sensitivity.
There is a solution. You can Set drag margin for your Navigation Drawer
Check this link
Set drag margin for Android Navigation Drawer
There is no need to do that since the users could easily pop open the Navigation Drawer by pressing the title area iff you implement the DrawerListenerinterface or the more convinient ActionBarDrawerToggle class to provide the 3 horizontal line icon indicating there is Navigation Drawer being present. Then you just override the onPostCreate() method in your Activity and call ActionBarDrawerToggle.syncState() method to allow users to open the drawer by pressing about the title area. Click here for more info on how to achieve that. Hope this helps

how to add actionbarsherlock menu to a fragment

I am using both actionbarsherlock and slidingmenu objects
the point is, I want my menu - which is sliding to do the following
push the currently visible screen aside, along with its actionbar
the fragment that is displayed inside the menu to have a different actionbar
how do i do that?
I've set everything to make 1 work
but the fragment is missing the menu - how to add it ?
You can't have multiple ActionBar in the same activity.
Best thing you could probably do, is not make the ActionBar slide with the menu, while starting/finishing an ActionMode when you open up/close the sliding menu.
Or if you really want to slide the ActionBar, then simply create a view in the menu fragment that will looks like an action bar.
You probably can use a custom layout in your actionbar and manipulate it by adding an animation so that it looks like the actionbar slides out and it is pushed by another actionbar when the menu slides in. The object would be the same, but the user perception will be of a sliding action bar pushing away the previous one.

Setting Navigation Icon on Android ActionBar

So I'm working on adding ActionBarSherlock and the Navigation Drawer to a project that previously implemented a custom (very poorly written) "action bar". Instead of using fragments and a backstack of activities for navigation, some activities show and hide different layouts. (That is, suppose I am in a list mode and then select a button to go into an edit screen. The app currently hides the list layout and shows another layout.).
So I've added actionbar sherlock and a navigation drawer to all the activities. I want to be able to programmatically switch the navigation icon from the 3 lines to the arrow when certain buttons are pressed.
I can't figure out how to do this though. Any ideas?
Thanks!
The solution to this problem is to use the method:
setDrawerIndicatorEnabled(boolean enable)
inside the ActionBarDrawerToggle class.
After:
drawer.setDrawerListener(toggle);
Use this code:
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.select);
It depends how wedded you are to built-in actionbar artifacts. You can always redraw the current actionbar by inflating a layout of your choosing, then calling
getSherlockActivity().getSupportActionBar().setDisplayShowTitleEnabled(false);
getSherlockActivity().getSupportActionBar().setDisplayShowHomeEnabled(false);
getSherlockActivity().getSupportActionBar().setDisplayShowCustomEnabled(true);
// Inflate and do whatever you need to your view...
getSherlockActivity().getSupportActionBar().setCustomView(abView);
getSherlockActivity().getSupportActionBar().show();
When you want to go back to your standard (assuming you're using a DrawerLayout to do your navigation drawer), you can just set make a call to setDisplayShowCustomEnabled(false) (re-enable showHome and showTitle as you please).
As far as I know, customization of the back button can only be done via themes. Besides, swapping the drawer icon for the back icon (within the same Activity) doesn't make sense, since users would still be able to access the navigation drawer by sliding the left most edge to the right. It just wouldn't make sense.
If you absolutely need the back icon, then it would make the most sense to make that screen a new Activity since you would indeed be adding another "level" to the stack, which is what the back icon represents.

drawer indicator with ActionBar compat

I have an application that is using the ActionBarCompat library as well as the NavigationDrawer support library.
I have managed to set up ActionBarDrawerToggle to get the drawer indicator on ICS+ devices, but it doesn't automatically enable it on Gingerbread devices with the ActionbarCompat.
Does anybody know of a way, or what changes I would need to make to the ActionBarCompat to enable the drawer indicator for those devices?
I managed to solve this by manually adding an image view as the first item in the ActionBarCompat, by modifying the construction of the compatibility bar in the library itself.
I believe the particular class in question is ActionBarHelperBase.java
Once this is in place, I animate it (similar to the real one) by translating the image in drawer open/close callbacks.
I say "similar" because the difference with my "hack" is that it will not animate until the drawer has finished opening/closing whereas the real one opens/closes WHILE the drawer is opening closing. it is a minor difference and doesn't/shouldn't cause too much issue.
There is not need to do conditional checking within the class because the code is only ever called for "compatible" ActionBars (i.e. pre-honeycomb).

Categories

Resources