1

Is it possible to put the toggle drawer button on the right side of the action bar? The toggle drawer button is the three bar icon on the left side. It turns into an arrow when drawer is opened (hence the arrow icon). I've already set my drawer on the right, but the button is still on the left. Or should I just make a custom one like that? But how can I use the same animation?

enter image description here

Lendl Leyba
  • 2,287
  • 3
  • 34
  • 49

1 Answers1

0

Steps that you have to follow :

  1. Make a menu.xml in menu folder :

  2. Inflate this menu in your activity and implement action over it :

    @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            //Inflating menu
            getMenuInflater().inflate(R.menu.main, menu);
            return super.onCreateOptionsMenu(menu);
        }
    
        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
        switch(item.getItemId()){
            case R.id.drawer : 
    
               //Open Drawer from right side
    
                   drawerLayout.openDrawer(Gravity.Right);
    
                     // or
    
                   drawerLayout.openDrawer(rightSlider); //right slider is right listview
    
                    break;
                  }
    
            return super.onOptionsItemSelected(item);
        }
    
  3. Finally in your layout xml file and inside drawer layout do like this :

    <!-- Framelayout to display Fragments -->
    
    <FrameLayout
        android:id="@+id/frame_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    </FrameLayout>
    
        <ListView
            android:id="@+id/right_slidermenu"
            android:layout_width="260dp"
            android:layout_height="match_parent"
          android:layout_gravity="end"
            android:background="@color/white"
            android:choiceMode="singleChoice"
            android:divider="@color/list_divider"
            android:dividerHeight="1dp"
            android:listSelector="@android:color/transparent"
            android:overScrollMode="never" />
    

Try this....it will help you..:)

Surender Kumar
  • 1,123
  • 8
  • 15
  • 1
    Sorry, but I already have the drawer opening from, and closing to, the right. What I need is for the original toggle drawer button, which is the three lines that animates into an arrow when drawer is open, be put on the right side, and pointing to the other side. Thank you tho :) – Lendl Leyba Apr 16 '15 at 06:46
  • You can change the icon of 3 lines icon to back arrow when drawer is open and change it again when drawer is closed. – Surender Kumar Apr 16 '15 at 07:39
  • but it happens automatically. and is there anyway to put that button on the right side? – Lendl Leyba Apr 16 '15 at 07:54
  • Actually, I didn't try this one, the only solution i know , i told you . – Surender Kumar Apr 16 '15 at 08:06
  • Well it's right, but I have a little more code. That's why it's not the answer I need. Thanks though. – Lendl Leyba Apr 16 '15 at 10:44