I have a drawer in my Android App. The drawer has a hamburger icon on the left side of the toolbar. I want to hide the hamburger icon. I use the following code:
我的Android应用程序中有一个抽屉。抽屉在工具栏的左侧有一个汉堡图标。我想隐藏汉堡包图标。我使用以下代码:
mDrawerToggle.setDrawerIndicatorEnabled(false);
The hamburger disappear, however, there is still a white space left, as is shown in the following img.
然而,汉堡包消失了,仍有一个空白区域,如下图所示。
How can I make the white space disappear?
如何让白色空间消失?
1 个解决方案
#1
5
set your toolbar navigation icon to null.
将工具栏导航图标设置为null。
toolbar.setNavigationIcon(null);
Refer doc it says
请参考文档说
Parameters icon
Drawable to set, may be null to clear the icon参数图标可绘制设置,可以为空以清除图标
------------Update----------
------------更新----------
If results remain same then create drawable of the color which is background of your toolbar. And set it as navigation icon.This hack should work.
如果结果保持不变,则创建工具栏背景颜色的drawable。并将其设置为导航图标。这个黑客应该工作。
naviation_drawable_icon.xml
naviation_drawable_icon.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="YOUR_COLOR_CODE"/>
</shape>
toolbar.setNavigationIcon(R.drawable.naviation_drawable_icon).
toolbar.setNavigationIcon(R.drawable.naviation_drawable_icon)。
#1
5
set your toolbar navigation icon to null.
将工具栏导航图标设置为null。
toolbar.setNavigationIcon(null);
Refer doc it says
请参考文档说
Parameters icon
Drawable to set, may be null to clear the icon参数图标可绘制设置,可以为空以清除图标
------------Update----------
------------更新----------
If results remain same then create drawable of the color which is background of your toolbar. And set it as navigation icon.This hack should work.
如果结果保持不变,则创建工具栏背景颜色的drawable。并将其设置为导航图标。这个黑客应该工作。
naviation_drawable_icon.xml
naviation_drawable_icon.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="YOUR_COLOR_CODE"/>
</shape>
toolbar.setNavigationIcon(R.drawable.naviation_drawable_icon).
toolbar.setNavigationIcon(R.drawable.naviation_drawable_icon)。