我開發了此解決方案以在操作欄中顯示通知。其結果是,操作欄圖標邊距
等你們,還有形狀沒有右限,我想是這樣的
我的代碼是從Actionbar notification count icon (badge) like Google has提取。這是我的代碼:
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>
誰能幫助我?