In my Android app, I show the actionbar and normally in the far left is my app's logo and to the left of the logo is the icon that lets you display the navigation drawer. This icon is typically 3 horizontally bars above each other.
After modifying my app, this menu icon is no longer visible. Instead, an arrow for "back" is now displayed.
I even have:
setDisplayHomeAsUpEnabled(false);
This gets rid of the arrow for navigating Up (or back) but the 3 bar menu item never shows. I still can press on my app's logo to the right and it will bring up the navigation drawer.
What is preventing the menu icon from showing?
I already have this problem and it was when I used a Fragment instead of an Activity. When you use an activity, you got the three lines to open the menu (if of course you enabled it), if you have a fragment, then you have an arrow.
I personnally use this :
ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
R.drawable.ic_drawer, //nav menu toggle icon
R.string.app_name, // nav drawer open - description for accessibility
R.string.app_name // nav drawer close - description for accessibility
)
Where the ic_drawer is the 3 bars icons. I use this tutorial to create my app Drawer.
Hopefully this can help you anyhow =)
Related
How to disable rotation animation on clicking 'navigation drawer indicator'
( hamburger icon) ?
I'm using a Htc model on geny motion emulator(1 GB ram). On clicking Navigation drawer icon, there is a slight lag on nav panel sliding (opening and closing).
So,I think, disabling animation would make sliding smoother.
(I'm using navigation drawer default template)
You can use the setDrawerSlideAnimationEnabled(boolean) to enable or disable the drawer arrow animation when the drawer position changes. An example of this would be:
// Installs drawer toggle
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout,
R.string.drawer_open, R.string.drawer_close);
// Disables animation
drawerToggle.setDrawerSlideAnimationEnabled(false);
How to Change the left side menu icon on the Action Bar ? I have created this using Navigation Drawer Fragment in Android Studio. Now an Arrow pointing left is displayed "<-" but i need to display the = icon. Where should i change this ?
You could use this format for your ActionBarDrawerToggle:
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
R.drawable.CUSTOM_ICON, // Navigation menu toggle icon
R.string.DRAWER_OPEN, // Navigation drawer open description
R.string.DRAWER_CLOSE // Navigation drawer close description
)
Change your drawable and make sure it is the same name as the one in the code.
To toggle the indicator you've to use:
public void toogleDrawer(boolean value){
mDrawerToggle.setDrawerIndicatorEnabled(!value);
getSupportActionBar().setDisplayHomeAsUpEnabled(value);
}
Please post the complete code relating to your drawer fragment, and action bar setup(if any) and also the relevant layouts. You've to research around a bit before asking the question. Check this question here : Cannot listen clicks on up caret
Everyone can provide specific answers to your problem if you add more content to it.
I'm using MaterialDrawer library to implement a basic material drawer in my app.
I wasted more than two days trying to figure out how to transform the menu toggle button (burger) to a back button, like Gmail app when you open an email.
In Gmail app when you open an email the menu icon is animated into a back arrow but the menu drawer remains still available.
I've tried to use ValueAnimator to animate the icon as explained here.
I've setted an onAnimationEnd listener to replace the menu icon with a working back button:
result.getActionBarDrawerToggle().setDrawerIndicatorEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
After doing that the menu drawer slide position get unlinked from the menu drawer icon animation, and when i try to restore the menu drawer button and animate it backwards it gets stuck:
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
result.getActionBarDrawerToggle().setDrawerIndicatorEnabled(true);
Actually a similar question has been already asked, and has been marked has duplicated when it is not: Navigation Drawer with Burger to back arrow animation on Lollipop
I changed all my previous tabs-activities app for a sliding_menu-fragments. The code to implement the sliding menu is using ActionBarDrawer (v4 which is deprecated now)
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
R.drawable.ic_drawer, //nav menu toggle icon
R.string.app_name, // nav drawer open - description for accessibility
R.string.app_name // nav drawer close - description for accessibility
)
The sliding menu is working fine. And the ic_drawer icon which is called the hamburguer (3 bars), appear well in my phone (One Plus One). Besides it, the app icon, appears also without problem.
But running the same app on a Samsung phone the app icon disappear. Just the hamburguer is showed.
Please if somebody was having a similar issue and have something to say I'll really appreciates any advice.
I am still struggling with finding a way to add padding/margin space between the navigation drawer icon in the action bar and the screen (top left of screen). Thanks in advance and I am trying to find any solution so either java or xml is perfect.
Regards,
Ryan
There is a tweak,
What you can do is that you can put the Navigation drawer icon to transparent and instead of application icon set the drawer icon.In that way the drawer icon will be moved away from left side of your screen.
ActionBar bar;
bar = getActionBar();
bar.setIcon(getResources().getDrawable(R.drawable.ic_drawer));//where R.drawable.ic_drawer is your drawer icon
ActionBarDrawerToggle mDrawerToggle;
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
R.drawable.ic_drawer_transparent, //nav menu toggle icon
R.string.app_name, // nav drawer open - description for accessibility
R.string.app_name // nav drawer close - description for accessibility
)
I hope this helps you in some way.
For padding, you can use:
ImageView view = (ImageView)findViewById(android.R.id.home);
view.setPadding(left, top, right, bottom);