1

I've implemented and Navigation Drawer which is currently appearing on the left side of the screen - however I'd like it to appear on the right side of the screen (with it's icon in the upper right hand corner of the screen as well - currently it is in the top left). I found the following SO article which explains how to do so:

http://stackoverflow.com/questions/18547277/how-to-set-navigation-drawer-to-be-opened-from-right-to-left/19358114#19358114

However when I attempt to implement the code the Navigation Drawer still appears on the left side.

Source (snippet):

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ss_home);

...

     mDrawerList = (ListView) findViewById(R.id.drawer_list);
     mDrawer = ( LinearLayout) findViewById(R.id.drawer);

     mDrawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout);

      mAdapter = new SimpleAdapter(this, mList, R.layout.drawer_layout, from, to);
     mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.icon_list_top_right , R.string.drawer_open){

         @Override
            public boolean onOptionsItemSelected(MenuItem item) {
                if (item != null && item.getItemId() == android.R.id.home) {
                    if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) {
                        mDrawerLayout.closeDrawer(Gravity.RIGHT);
                    } else {
                        mDrawerLayout.openDrawer(Gravity.RIGHT);
                    }

                }
                return false;
            }

XML Layout Files/Source:

http://pastebin.com/NhskGCCB

If there is any additional information necessary I will be more than happy to provide it (I'm just stumped as to why the NavBar isn't appearing on the right side of the screen)

Jackie Deezner
  • 217
  • 3
  • 12

2 Answers2

0

The android:layout_gravity="start" on the LinearLayout id="drawer" should be set to android:layout_gravity="end".

Sidenote: This XML structure is poorly constructed, why are the id="drawer" and id="left_drawer" ViewGroups's siblings - and not nested? Why is the FrameLayout id="content_frame" empty?

Evan Bashir
  • 5,501
  • 2
  • 25
  • 29
0

You actually have left and right navigation drawers in your layout (id : drawer and id : left_drawer). I have just tested it and both of them loads fine on left and right swipe.

If you want to have burger icon on right side, hide existing and add another one as image view to your toolbar. After that you can bind click on it and open your navigation drawer programmatically.

nsi
  • 1
  • 3