Search code examples
androidnavigation-draweractionbardrawertoggle

How can I change the actionbardrawertoggle icon, android?


In my activity I want to change the drawer toggle icon I have my toolbar

 <android.support.v7.widget.Toolbar
    android:id="@+id/tool_bar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="@color/appColor"
    android:minHeight="?attr/actionBarSize"
    app:theme="@style/MyDarkToolbarStyle">


</android.support.v7.widget.Toolbar>

This is the toolbar theme

 <style name="MyDarkToolbarStyle" parent="Widget.AppCompat.Toolbar">
    <item name="android:gravity">center_vertical</item>
    <!--<item name="popupTheme">@style/PopupMenuStyle</item>-->
    <item name="actionButtonStyle">@style/MyActionButtonStyle</item>

</style>

This is the activity theme

 <style name="MyMaterialTheme.Base" parent="Theme.AppCompat">
    <item name="android:windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">@color/ColorPrimary</item>
    <item name="colorPrimaryDark">@color/ColorPrimaryDark</item>
</style>

Solution

  • Use below code snippet to set your custom actionbar toggle button.

      mDrawerToggle.setDrawerIndicatorEnabled(false);
    
                // mDrawerToggle.setHomeAsUpIndicator(R.drawable.menu_icon);
                mToolbar.setNavigationIcon(R.drawable.menu_icon);
    
                mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        mDrawerLayout.openDrawer(Gravity.LEFT);
                    }
                });