Remove Android Toolbar Navigation Drawer option
Asked Answered
B

6

6

How can i remove the leftmost navigation drawer menu item on the Android Toolbar. Basically i wan't to contain 4 images in a horizontal fashion, Nothing else !

Breana answered 15/2, 2015 at 4:6 Comment(1)
None of answers workingHypogynous
N
10

getSupportActionBar().setDisplayHomeAsUpEnabled(false)

This should remove the navigation drawer icon

Niello answered 15/2, 2015 at 4:35 Comment(0)
S
9

Use

yourActionBarDrawer.setDrawerIndicatorEnabled(false);

This will remove the hamburger icon on toolbar completely.

Shiftless answered 1/7, 2015 at 22:4 Comment(0)
I
8

My solution:

DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.ACCEPT, R.string.CANCEL);
drawer.setDrawerListener(toggle);
toggle.syncState();
toggle.setDrawerIndicatorEnabled(false);
Iloilo answered 19/10, 2016 at 11:21 Comment(0)
S
6

Might be late but you can get the reference to the Toolbar:

Toolbar toolbar = (Toolbar) findViewById(R.id.yourToolbarId);

then

toolbar.setNavigationIcon(null);

Reference here: https://developer.android.com/reference/android/widget/Toolbar.html#setNavigationIcon(android.graphics.drawable.Drawable)

Parameters icon
Drawable to set, may be null to clear the icon

EDIT: if the title doesn't look aligned call:

toolbar.getMenu().clear();
Shoreward answered 7/10, 2015 at 22:2 Comment(0)
O
2

To remove the totally unfashionable margin who have the toolbar in the left side for a posible navigation icon you should do:

toolbar.setContentInsetsAbsolute(0,0);
Ochrea answered 9/6, 2016 at 12:36 Comment(1)
this unswer helps me when i am using fragment with AppBarLayout and Toolbar in itFlaxen
C
0
    final ActionBar ab = getSupportActionBar();
    if (ab != null)
    {
        ab.setDisplayHomeAsUpEnabled(false);
    }
Cadi answered 29/3, 2018 at 6:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.