简体   繁体   English

“@android:style / TextAppearance.StatusBar.EventContent.Title”在android L中将颜色设置为白色而不是灰色

[英]“@android:style/TextAppearance.StatusBar.EventContent.Title” sets the color to white instead of grey in android L

Android L uses white background for notifications and grey color for the text on it. Android L使用白色背景作为通知,使用灰色作为文本。 But, "@android:style/TextAppearance.StatusBar.EventContent.Title" still sets the color of TextView to same white color like in KitKat or previous versions. 但是, "@android:style/TextAppearance.StatusBar.EventContent.Title"仍然将TextView的颜色设置为与KitKat或以前版本中相同的白色。 It should return the grey color used in new notification style of Android L. 它应该返回Android L的新通知样式中使用的灰色。
How can I solve it? 我该如何解决? Thanks in advance. 提前致谢。

It seems android-L doesn't override "@android:style/TextAppearance.StatusBar.EventContent.Title" , instead introduces new style 似乎android-L没有覆盖"@android:style/TextAppearance.StatusBar.EventContent.Title" ,而是引入新风格

<style name="TextAppearance.Material.Notification.Title">
    <item name="textColor">@color/primary_text_default_material_light</item>
    <item name="textSize">@dimen/notification_title_text_size</item>
</style>

We could make use of both the API based values folders to handle this in proper way. 我们可以使用基于API的值文件夹来以正确的方式处理它。

/values/styles.xml

<style
    name="NotificationTitle"
    parent="@style/TextAppearance.StatusBar.EventContent.Title" />

/values-21/styles.xml

<style
    name="NotificationTitle"
    parent="@android:style/TextAppearance.Material.Notification.Title" />

Now call the following line in your TextView 现在在TextView调用以下行

android:textAppearance="@style/NotificationTitle"

Here is what worked for me to resolve this error. 以下是解决此错误的方法。 In your styles.xml , add the following: styles.xml ,添加以下内容:

    <style name="TextAppearance">
    </style>
    <style name="TextAppearance.StatusBar">
    </style>
    <style name="TextAppearance.StatusBar.EventContent">
        <item name="android:textColor">#ff6b6b6b</item>
    </style>
    <style name="TextAppearance.StatusBar.EventContent.Info">
        <item name="android:textColor">#ff6b6b6b</item>
    </style>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM