我有和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