A
A
afna2015-10-08 12:21:38
Java
afna, 2015-10-08 12:21:38

How to place the open side menu button on the right?

Good afternoon!
Understanding the side menu on Android. Looked at this article .
The task was to open the side menu on the right. Not a question, set up the opening on the right:

mDrawerToggle = new ActionBarDrawerToggle(this, Drawer, toolbar, R.string.drawer_open, R.string.drawer_close) {
            @Override
            public void onDrawerOpened(View drawerView) {
                super.onDrawerOpened(drawerView);
                // code here will execute once the drawer is opened( As I dont want anything happened whe drawer is
                // open I am not going to put anything here)
            }
            @Override
            public boolean onOptionsItemSelected(MenuItem item) {
                if (item != null && item.getItemId() == android.R.id.home) {
                    if (Drawer.isDrawerOpen(Gravity.RIGHT)) {
                        Drawer.closeDrawer(Gravity.RIGHT);
                    } else {
                        Drawer.openDrawer(Gravity.RIGHT);
                    }
                }
                return false;
            }
            @Override
            public void onDrawerClosed(View drawerView) {
                super.onDrawerClosed(drawerView);
                // Code here will execute once drawer is closed
            }
        };

But the button in the Toolbar remained on the left . I just can't place the "sandwich" on the right.
How to place the menu open button on the right, and the rest of the toolbar buttons on the left?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
afna, 2015-10-08
@sulik93

Already tried that.
My child element:

<android.support.v7.widget.RecyclerView
            android:id="@+id/RecyclerView"
            android:layout_width="320dp"
            android:layout_height="match_parent"
            android:layout_gravity="end"
            android:background="#ffffff"
            android:scrollbars="vertical">

    </android.support.v7.widget.RecyclerView>

I tried it and so android:layout_gravity="right"
I understand, this affects which side the side menu opens from. But the button in the toolbar still remains on the left, but it should be on the right (from the side of the side menu opening)

O
Oleg Gamega, 2015-10-08
@gadfi

DrawerLayout

Drawer positioning and layout is controlled using the android:layout_gravity attribute on child views corresponding to which side of the view you want the drawer to emerge from: left or right. (Or start/end on platform versions that support layout direction.)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question