Search code examples
androidxmlandroid-intentandroid-actionbarandroid-optionsmenu

Arrow missing from share icon within action bar


After creating a menu for my action bar. The little arrow doesn't appear next to the share icon and I'm not sure why this has happened or if it's intentional based on my code. enter image description here

<?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:id="@+id/action_info"
        android:title="@string/information"
        android:icon="@android:drawable/ic_menu_info_details"
        app:showAsAction="ifRoom"/>

    <item android:id="@+id/action_share"
        android:title="@string/menuitem_share"
        android:icon="@android:drawable/ic_menu_share"
        app:actionProviderClass="android.support.v7.widget.ShareActionProvider"
        app:showAsAction="ifRoom"/>

    <item android:id="@+id/action_preferences"
        android:title="@string/menuitem_preferences"
        app:showAsAction="never"/>

</menu>

After viewing images of similar menus online, I noticed that little arrow (in this screenshot).

enter image description here

How can that little arrow be added to the share icon?


Solution

  • As far as I know, every new project you create in Android Studio uses the Material design (introduced with Android 5.0 Lollipop) with AppCompat themes. It is designed to show up on every compatible device thanks to Support Library (even on pre-Lollipop devices), and ActionBar menu items created when you are using Support Library looks like on the first image.

    As far as I also know, I've seen this kind of arrowed Share button on the second image last time on a 4.x device. So I think you could re-create this kind of Share button if you would not use any theme and let your pre-Lollipop device to do the work with the ActionBar.

    I've tried to recreate this behaviour by your code above, without luck. But then I opened the ApiDemos app which is on every Android Studio emulator image and shows a lot of functions built up in Android, for example ActionBar functions. There I saw that Share button looks differently on different API levels.

    Android 4.4 KitKat:

    enter image description here

    Android 5.0 Lollipop:

    enter image description here