Can't display an icon in the actionbar

后端 未结 2 1834
后悔当初
后悔当初 2021-01-14 03:33

I\'m trying to show a map icon downloaded from the official android developers source.

I did everything as it should, but the icon won\'t show. Here is my xml file n

相关标签:
2条回答
  • 2021-01-14 04:15

    I dont think an icon is shown in the overflow menu. Try changing your title to "t" or rotate the screen. See if the icon appears this way.

    0 讨论(0)
  • 2021-01-14 04:33

    Here is how I fixed it - in case that someone is facing the same issue.

    I changed

    android:showAsAction="always" to app:showAsAction="always" and I also placed the icon order android:orderInCategory="0" and the auto res xmlns:app="http://schemas.android.com/apk/res-auto" so now my xml looks like:

    <?xml version="1.0" encoding="utf-8"?>
    <menu xmlns:android="http://schemas.android.com/apk/res/android" 
          xmlns:app="http://schemas.android.com/apk/res-auto">
    
        <item
            android:orderInCategory="0"
            android:id="@+id/mapIcon"
            android:icon="@drawable/ic_action_map"
            android:title="@string/mapIconTitle"
            app:showAsAction="always"
         />
    
    </menu>
    
    0 讨论(0)
提交回复
热议问题