我有和this post完全一樣的問題。我希望我的自定義通知文本樣式匹配默認通知(我只是想添加一些額外的視圖)。不幸的是,我不完全理解接受的答案。我想我的意思添加到XML代碼,但不知道到底是什麼...... 如何使用默認通知樣式?
接受的答案說:」 的解決方案是使用內置樣式,你需要的風格是TextAppearance.StatusBar。 EventContent。只需應用這種風格,它將設置通知的默認文本顏色(當然,不要忘記android:前綴)。 「
我不能得到這個工作!在我的自定義通知下面的行「android:textAppearance =」?android:attr/textAppearanceLarge「作品(因爲它擴大了文字),但沒有給出預期的效果。
這是我的自定義XML代碼...
<ImageView
android:id="@+id/notImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_alignParentTop="true"/>
<TextView
android:id="@+id/notContentTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf ="@id/notImage"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/notContentText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below ="@id/notContentTitle"
/>
Custom notification layouts and text colors
只是讓我們很清楚...有沒有辦法用API9之前默認的通知樣式,是否正確? – 2011-07-01 18:25:14
不幸的是,是的。正如我在我的回答(http://stackoverflow.com/questions/4867338/custom-notification-layouts-and-text-colors/4935191#4935191)中所解釋的,在API Level 8及更早版本中,只有一個硬編碼值,無法訪問。 – Malcolm 2011-07-18 18:57:57
答案(http://stackoverflow.com/a/7320604/435605)確實提供了一種方法來查找2.2- – 2011-12-06 19:36:39