简体   繁体   中英

How to show the hidden Navigation Drawer Hamburger icon?

I have hidden the navigation drawer hamburger icon using the following code in onCreate.

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

When I move to other fragments also this is hidden, how can I bring the icon back once I move away from this fragment?

您可以使用drawable设置图标

actionBar.setHomeAsUpIndicator(R.drawable.hamburger_icon);

try this to get deafult hamburger_icon drawable

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

crate this ic_drawer.xml in drawable folder

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM