How to change three dots button on android to other button

If you want to add other icon instead of 3 dots then just create menu.xml like below code:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item android:id="@+id/menu_item_add"
    android:title="Add"
    app:showAsAction="always"
    android:icon="@drawable/ic_add" />
</menu>

Note: Don't use android:showAsAction. Use app:showAsAction.


//just edit menu.xml file    
//add icon for item which will change default setting icon
//add sub menus


 ///menu.xml file


    <item
            android:id="@+id/action_settings"
            android:orderInCategory="100"
            android:title="@string/action_settings"
            android:icon="@drawable/your_icon"
            app:showAsAction="always" >

            <menu>

                <item android:id="@+id/action_menu1"
                    android:icon="@android:drawable/ic_menu_preferences"
                    android:title="menu setting" />

                <item android:id="@+id/action_menu2"
                    android:icon="@android:drawable/ic_menu_help"
                    android:title="help" />

            </menu>
        </item>

Sorry i can't reply as a comment, but i'm guessing you want to change the actionbar overflow menu icon. If so you can do it in styles.xml.

 <!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
    <!-- All customizations that are NOT specific to a particular API-level can go here. -->
    <item name="android:actionOverflowButtonStyle">@style/MyActionButtonOverflow</item>
</style>

<!-- Style to replace actionbar overflow icon. set item 'android:actionOverflowButtonStyle' in AppTheme -->
<style name="MyActionButtonOverflow" parent="android:style/Widget.Holo.Light.ActionButton.Overflow">
    <item name="android:src">@drawable/ic_launcher</item>
</style>

Original post: How to change option menu icon in the action bar?


Sorry I don't have enough reputation to post a comment. Here is the best answer I found, its one line of code:

myToolbar.setOverflowIcon(ContextCompat.getDrawable(getApplicationContext(),R.drawable.my_drawable));

The link for the original answer is here: https://stackoverflow.com/a/35790470/4575772

Tags:

Android