How can i set ActionBarDrawerToggle at right corner ? because i set listview gravity
android:layout_gravity="end"
so i want ActionBarDrawerToggle to be at right , How can i do that ??
this is my code
getActionBar().setDisplayHomeAsUpEnabled(true);
getActionBar().setHomeButtonEnabled(true);
mDrawerToggle = new ActionBarDrawerToggle(this,mDrawerLayout,R.drawable.ic_drawer,R.string.drawer_open,R.string.drawer_close)
{
public void onDrawerClosed(View view) {
getActionBar().setTitle(mTitle);
invalidateOptionsMenu();
}
public void onDrawerOpened(View drawerView) {
getActionBar().setTitle(mDrawerTitle);
invalidateOptionsMenu();
}
};
I can't do this using the click on "home" icon, and I think this wouldn't be good because drawer will appear in the right side. But, as @runamok, I want to have an option menu item (as opposed to replacing the "home" icon which normally performs "back" functionality) on the right side which triggers the drawer to transition in/out from the right.
Besides using android:layout_gravity="right", use an option menu item to perform the open/close movement.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.my_menu_item:
if(!mDrawerLayout.isDrawerOpen(Gravity.RIGHT))
mDrawerLayout.openDrawer(Gravity.RIGHT);
else
mDrawerLayout.closeDrawer(Gravity.RIGHT);
return true;
default:
break;
}
return super.onOptionsItemSelected(item);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With