如何显示隐藏的导航抽屉汉堡图标?

时间:2017-09-07 09:15:47

标签: android android-navigation-drawer

我使用onCreate中的以下代码隐藏了导航抽屉汉堡包图标。

 final android.support.v7.app.ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
        if(actionBar!=null) {
            actionBar.setHomeAsUpIndicator(null);
        }

当我移动到其他片段时,这也是隐藏的,一旦我离开这个片段,我怎么能把图标带回来?

2 个答案:

答案 0 :(得分:1)

您可以使用drawable

设置图标
processFunction(){
    ....
    ....
    this.someVar = this.someService.getData();
    ....
    ....
    this.functionA(); //funcA needs this.someVar
    this.functionB(); //funcB needs this.someVar
}

答案 1 :(得分:0)

试试这个以获得聋人hamburger_icon drawable

actionBar.setHomeAsUpIndicator(R.drawable.ic_drawer);
actionBar.setDisplayHomeAsUpEnabled(true);

在可绘制文件夹

中创建 ic_drawer.xml
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:fillColor="#FF000000"
        android:pathData="M3,18h18v-2L3,16v2zM3,13h18v-2L3,11v2zM3,6v2h18L21,6L3,6z"/>
</vector>
相关问题