Android TextView中的纯色背景和文本显示比它们应该更暗

时间:2012-03-19 21:23:53

标签: android colors textview

例如,如果我将背景颜色设置为#FF0000,我希望亮红色。但是,我变成了深红色。如果我将背景设置为#FFFFFF,我会变灰而不是白色。

我注意到,如果我将应用程序的主题从暗处切换为浅色,那么所有颜色都会比我预期的要亮,所以红色会变成红色,而黑色会变成灰色。

有谁知道为什么会这样?

更多信息:这是我的布局:

(我正在尝试在单击时将TextView的背景从黑色更改为白色。)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >

    <ListView android:id="@+id/wordList"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1.0" />

    <TextView android:id="@+id/addButton"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:padding="10dp"
        android:textSize="20sp"
        android:textStyle="bold"
        android:gravity="center_horizontal"
        android:background="@color/black"
        android:text="@string/add_button"
        android:textColor="@color/white"
        android:clickable="true"/>  

</LinearLayout>

1 个答案:

答案 0 :(得分:0)

您缺少Alpha通道。颜色的格式为#AARRGGBB,其中AA是透明度。对于明亮不透明的红色,你应该尝试#FFFF0000。