How to disable DrawerArrowToggle from toolbar or move to the right

first question: I want to create a toolbar from right to left as shown in the picture:

right to left toolbar

How do I set up the DrawerArrowToggle panel to move to the right?

And second question: I am creating a custom toolbar and creating a button for an open drawer, but the DrawerArrowToggle pane appears to the left of my custom toolbar. enter image description here how to remove it?

- update -

with sasikumar adding this line DrawerArrowToggle removed.

mDrawerToggle.setDrawerIndicatorEnabled(false);

      

here's my toolbar code:

 LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.action_bar, null);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    actionBar.setCustomView(view, new ActionBar.LayoutParams
            (ViewGroup.LayoutParams.MATCH_PARENT,
                    ViewGroup.LayoutParams.MATCH_PARENT));
    Toolbar parent = (Toolbar) view.getParent();
    parent.setContentInsetsAbsolute(0, 0);



Drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerToggle = new ActionBarDrawerToggle(this, Drawer,
            parent, R.string.openDrawer,
            R.string.closeDrawer) {
        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);


        }

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);

        }

        @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;
        }
    };
    Drawer.setDrawerListener(mDrawerToggle);
    mDrawerToggle.syncState();

      

my app for app looks like this: sample right to left toolbar

sorry for bad english.

+3


source to share


3 answers


you can hide the arrow using the onDrawerSlide method.

drawerToggle = new ActionBarDrawerToggle(this, drawerLayout,
    getToolbar(), R.string.open, R.string.close) {

@Override
public void onDrawerClosed(View view) {
    super.onDrawerClosed(view);
}

@Override
public void onDrawerOpened(View drawerView) {
    super.onDrawerOpened(drawerView);
}
 @Override
public void onDrawerSlide(View drawerView, float slideOffset) {
    super.onDrawerSlide(drawerView, 0); // this disables the animation 
}
};

      

If you want to completely remove the arrow, you can add



super.onDrawerSlide(drawerView, 0); // this disables the arrow @ completed state

      

at the end of the onDrawerOpened function

+2


source


Check out the link below, maybe helpful:

How to open the navigation drawer from right to left



and this link too:

Android - is a navigation drawer on the right side possible?

+1


source


You seem to have added the rest of the code. Just set the gravity to the right. as...

android:layout_gravity="right"

now set the position of the box to the right using the following code:

mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, 
        R.drawable.ic_drawer, R.string.drawer_open, 
        R.string.drawer_close) { 

    @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; 
    } 
};

      

+1


source







All Articles