Search code examples
androidxmlxamarinmenumenuitem

Android Menu item Customization


I have an Xamarin android menu ui code as follows

<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <group
        android:checkableBehavior="single">
        <item
            android:id="@+id/sync_now"
            android:checked="false"
            android:icon="@drawable/ic_logo"
            android:title="Sync Now"/>
    </group> 
</menu>

I am trying to get a split view on this hazard icon along with the transactions count displayed on the right side of the menu group items shown in the image below but am having no luck. enter image description here

can someone please tell me how i can do this?


Solution

  • I achieved the above ui by creating a different layout file for everything after sync and added it to the item tag as:

    <item
            android:id="@+id/sync_now"
            android:checked="false"
            android:icon="@drawable/ic_syncNow"
            android:title="Sync Now"
            app:actionLayout="@layout/syncNowCounter"/>
    

    make sure you use app:actionLayout instead of android:actionLayout or it will not work.