I have developed this solution to show notifications in the actionbar. The result is that
Like can you there is no right margin in the shape and I want something like this
My code is extracted from Actionbar notification count icon (badge) like Google has. And this is my code:
main.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/badge"
android:actionLayout="@layout/feed_update_count"
android:icon="@layout/custom_shape_notification"
android:showAsAction="always">
</item>
</menu>
custom_shape_notifications.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<stroke
android:width="2dp"
android:color="#22000000" />
<corners android:radius="5dp" />
<solid android:color="#CC0001" />
feed_update_count.xml
<?xml version="1.0" encoding="utf-8"?>
<Button xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/notif_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minWidth="32dp"
android:minHeight="32dp"
android:background="@layout/custom_shape_notification"
android:text="1"
android:textSize="16sp"
android:textColor="@android:color/white"
android:gravity="center"
android:padding="2dp"
android:singleLine="true">
</Button>
Can anyone help me?