I have created drawer layout sample application, it's working fine, my problem is drawer layout working in right to left perfectly but I am trying to move icon left side to right side but it's not working give me your suggestion..!!! This is possible or not?
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="right" >
<!-- The main content view -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<!-- The navigation drawer -->
<ListView
android:id="@+id/drawer_list"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="right"
android:background="#111"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
</android.support.v4.widget.DrawerLayout>
set DrawerLayout tools:openDrawer="end" set NavigationView android:layout_gravity="end" change tag view from androidx.
The navigation drawer is a UI panel that shows your app's main navigation menu. The drawer appears when the user touches the drawer icon in the app bar or when the user swipes a finger from the left edge of the screen.
Maybe it's too late but you can solve this using the default Menu.
Create res/menu/my_right_side_menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/btnMyMenu"
android:icon="@drawable/ic_drawer"
android:title="Right Side Menu"
myapp:showAsAction="always"/>
</menu>
Then add your menu in onCreateOptionsMenu()
in your Activity
@Override
public boolean onCreateOptionsMenu(Menu menu) {
int menuToUse = R.menu.my_right_side_menu;
MenuInflater inflater = getMenuInflater();
inflater.inflate(menuToUse, menu);
return super.onCreateOptionsMenu(menu);
}
Next, in your ActionBarDrawerToggle
handle the click event of your menu item
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) {
@Override
public boolean onOptionsItemSelected(android.view.MenuItem item) {
if (item != null && item.getItemId() == R.id.btnMyMenu) {
if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) {
mDrawerLayout.closeDrawer(Gravity.RIGHT);
} else {
mDrawerLayout.openDrawer(Gravity.RIGHT);
}
return true;
}
return false;
}
};
And finally don't forget to hide your Home button from the ActionBar
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
getSupportActionBar().setDisplayShowHomeEnabled(false);
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