删除Android工具栏导航抽屉选项

时间:2015-02-15 04:06:44

标签: android navigation-drawer android-toolbar

如何删除Android工具栏上最左侧的导航抽屉菜单项。基本上我不想以横向方式包含4幅图像,没有别的!

6 个答案:

答案 0 :(得分:9)

使用

yourActionBarDrawer.setDrawerIndicatorEnabled(false);

这将完全删除工具栏上的汉堡包图标。

答案 1 :(得分:8)

getSupportActionBar()。setDisplayHomeAsUpEnabled(假)

这应删除导航抽屉图标

答案 2 :(得分:7)

我的解决方案:

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);

答案 3 :(得分:2)

可能会迟到但您可以获得对工具栏的引用:

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

然后

toolbar.setNavigationIcon(null);

参考此处:https://developer.android.com/reference/android/widget/Toolbar.html#setNavigationIcon(android.graphics.drawable.Drawable)

  

参数图标
  Drawable to set,可以为null以清除图标

编辑:如果标题看起来不对齐,请致电:

toolbar.getMenu().clear();

答案 4 :(得分:2)

要删除左侧有工具栏的完全不合时宜的边距,您应该执行以下操作:

toolbar.setContentInsetsAbsolute(0,0);

答案 5 :(得分:0)

    final ActionBar ab = getSupportActionBar();
    if (ab != null)
    {
        ab.setDisplayHomeAsUpEnabled(false);
    }