简体   繁体   中英

“@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. But, "@android:style/TextAppearance.StatusBar.EventContent.Title" still sets the color of TextView to same white color like in KitKat or previous versions. It should return the grey color used in new notification style of 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

<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.

/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

android:textAppearance="@style/NotificationTitle"

Here is what worked for me to resolve this error. In your styles.xml , add the following:

    <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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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