Home > Mobile >  How to add image beside text in an option menu?
How to add image beside text in an option menu?

Time:09-24

I want to know if there a solution to add an image next to a text in the option menu in xml like the photo:
ZArchives

CodePudding user response:

by adding icon attribute to your menu item xml and setting show as action to never like that :

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

    <item
        android:id="@ id/favorite"
        android:icon="@drawable/ic_favorite_24dp"
        android:title="@string/favorite"
        android:contentDescription="@string/content_description_favorite"
        app:showAsAction="never" />
</menu>

where the ic_favorite_24dp could be any image/vector asset icon drawable you like in your drawables folder.

check this link and this link for more information

  • Related