3

I am using ActionBarDrawerToggle (Navigation Drawer), but I can't set it on the right corner (for persian language).

Here is my activity_main.xml code:

<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">

    <!-- Framelayout to display Fragments -->
    <FrameLayout   
        android:id="@+id/frame_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />  

    <!-- Listview to display slider menu -->
    <ListView
        android:id="@+id/list_slidermenu"
        android:layout_width="240dp"
        android:layout_height="match_parent"  
        android:layout_gravity="start"
        android:choiceMode="singleChoice"
        android:divider="@color/list_divider"
        android:dividerHeight="1dp"        
        android:listSelector="@drawable/list_selector"
        android:background="@color/list_background" />

</android.support.v4.widget.DrawerLayout>

And this is relevant code from my activity class:

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) {
        public void onDrawerClosed(View view) {
            getActionBar().setTitle(mTitle);
            // calling onPrepareOptionsMenu() to show action bar icons
            invalidateOptionsMenu();
        }

        public void onDrawerOpened(View drawerView) {
            getActionBar().setTitle(mDrawerTitle);
            // calling onPrepareOptionsMenu() to hide action bar icons
            invalidateOptionsMenu();
        }          
}; 

I searched about this, I should use gravity, but it it is not working in xml.

Darwind
  • 7,284
  • 3
  • 49
  • 48
Nima.S-H
  • 777
  • 1
  • 9
  • 19
  • it does not work because 'start' works on the type of language that you are using. if your language is Right-to_left, then the drawer will appear on right. I think you should check your language pattern and then try again. – Aradhna Jun 21 '14 at 06:16
  • I use of 'end' and 'right',but still dosen't work – Nima.S-H Jun 21 '14 at 06:20
  • 1
    check this-> http://stackoverflow.com/questions/18547277/how-to-set-navigation-drawer-to-be-opened-from-right-to-left – Aradhna Jun 21 '14 at 06:29

2 Answers2

3
toolbar.setNavigationOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
    if (Drawer.isDrawerOpen(Gravity.RIGHT)) {
        Drawer.closeDrawer(Gravity.RIGHT);
    } else {
        Drawer.openDrawer(Gravity.RIGHT);
    }
}});
SadeQ digitALLife
  • 1,403
  • 4
  • 16
  • 22
-2

Try adding this line to android manifest file:

android:supportsRtl="true"
Tyler
  • 17,669
  • 10
  • 51
  • 89
n.b
  • 5
  • 2