如何搭配通知颜色栏文字颜色? [英] How to match text color with notification color bar?

查看:275
本文介绍了如何搭配通知颜色栏文字颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中使用白色字体这是我的电话,有一个黑色主题的还好。
但在其他手机通知栏的颜色和菜单背景颜色为白色或浅色。有没有什么办法知道什么样的颜色或深/浅色主题的使用手机,并匹配字体颜色(给用户的选项,选择在应用程序设置的颜色旁)?

My application use white color font which is okay on my phone that has a black theme. But on other phone the notification bar color and the menus background color is white or a light color. Is there any way (beside giving the user the option to chose the color in the app settings) to know what kind of color or dark/light theme use the phone and match the font color ?

推荐答案

当您使用的通知,并通过内置的方式设置文本,以下行创建的布局:

When you use Notification and set the text by using built-in means, the following line creates the layout:

RemoteViews contentView = new RemoteViews(context.getPackageName(),
        com.android.internal.R.layout.status_bar_latest_event_content);

所提到的布局包含以下查看它负责查看通知文本:

The mentioned layout contains the following View which is responsible for viewing notification text:

<TextView android:id="@+id/text"
    android:textAppearance="@style/TextAppearance.StatusBar.EventContent"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:singleLine="true"
    android:ellipsize="marquee"
    android:fadingEdge="horizontal"
    android:paddingLeft="4dp"
    />

所以得出的结论是,需要的风格是TextAppearance.StatusBar.EventContent,它的定义是这样的:

So the conclusion is that the needed style is TextAppearance.StatusBar.EventContent, which definition looks like this:

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

您应该在这里指出,这种风格实际上并没有引用任何的内置的色彩,所以最安全的方法是应用而不是这种风格的一些内置的颜色。

You should note here that this style doesn't actually reference any of the built-in colors, so the safest way is to apply this style instead of some built-in color.

这篇关于如何搭配通知颜色栏文字颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆