8

请举例说明在 Android 上使用 XML 指定 RGB 格式的颜色。语法是 #rrggbb.

4

2 回答 2

21

您可以像这样在 XML 中指定 RGB 格式的颜色:

<TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:text="Test text"
            android:textColor="#332116"
            android:textSize="16sp"
            android:textStyle="bold" />

一般形式:

android:textColor="#332116" is "#rrggbb"
于 2012-10-22T04:40:31.317 回答
3

提供任何背景颜色

android:background="#rrggbb"

为文本提供颜色

android:textcolor="#rrggbb"

您可以使用此页面以十六进制格式找出正确的 RGB 值

选色器

在 xml 中指定注释

    <!--android:textColor="#332116"-->
<TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:text="Test text"
            android:textColor="#332116"
            android:textSize="16sp"
            android:textStyle="bold" />
于 2012-10-22T04:39:10.180 回答