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

6
我该如何在Android工具栏中删除最左边的导航抽屉菜单项?基本上,我想要以水平方式包含4张图像,仅此而已!

没有一个答案可用。 - IntoTheDeep
6个回答

10

getSupportActionBar().setDisplayHomeAsUpEnabled(false)

这将移除导航抽屉图标。


9
使用
yourActionBarDrawer.setDrawerIndicatorEnabled(false);

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


8

我的解决方案:

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

6

2
为了去掉在左侧工具栏可能出现的导航图标的完全不时髦的边距,您应该执行以下操作:
toolbar.setContentInsetsAbsolute(0,0);

这个答案在我使用带有AppBarLayout和Toolbar的Fragment时非常有帮助。 - Alexandro

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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接