Search code examples
androidhamburger-menudrawertoggle

HamBurger Icon in ActionBar


I want to use a hamburger icon on the right side of my action bar. But it's showing an arrow sign. I have included Library AppCompatV7 and extending my class from Activity. Can someOne please give the solution. I have tried many solutions but none is working.


Solution

  • Open Android Manifest, check what theme you are using. I was using AppTheme for my main activity

    <application
            android:allowBackup="true"
            android:icon="@mipmap/ic_launcher"
            android:label="@string/app_name"
            android:supportsRtl="true"
            android:theme="@style/AppTheme">
            <activity
                android:name=".FrontPageActivity"
                android:label="@string/app_name">
            </activity>
    

    2) Open res/values/styles, make sure your theme includes the attribu "drawerArrowStyle", then create a new style for that to change the value for "spinBars" to true.

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
            <!-- Customize your theme here. -->
            <item name="colorPrimary">@color/colorPrimary</item>
            <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
            <item name="colorAccent">@color/colorAccent</item>
            <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
        </style>
    
        <style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
            <item name="spinBars">true</item>
            <item name="color">@android:color/white</item>
        </style>
    

    ...it took me a while to piece that one together.