我在自定义布局上放了一个TextView来显示通知,但是TextView的颜色会自动变为白色。这是安卓的一个bug吗?因为在Lollipop之前,通知背景色通常是深色,所以白色文本是有意义的。而现在在Lollipop上,默认背景是白色,所以白色文本就看不见了。
或者说我应该显式地设置文本颜色吗?加上android:textColor="@android:color/primary_text_light"可以将文本变为黑色,但不能保证所有Lollipop设备的通知背景都是白色,对吗?
那么正确的方法是什么,如何确保自定义通知中的文本始终可见,无论系统的背景颜色是什么?
Android Studio预览:
实际5.1.1设备上:
或者说我应该显式地设置文本颜色吗?加上android:textColor="@android:color/primary_text_light"可以将文本变为黑色,但不能保证所有Lollipop设备的通知背景都是白色,对吗?
那么正确的方法是什么,如何确保自定义通知中的文本始终可见,无论系统的背景颜色是什么?
Android Studio预览:
![Preview on Android Studio](https://istack.dev59.com/rb0Ei.webp)
![On actual 5.1.1 device](https://istack.dev59.com/pRHjz.webp)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, world"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button 2"/>
</LinearLayout>