请给出一个示例,说明使用Android上的XML指定RGB形式的颜色。语法为 #rrggbb
。
您可以在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"
提供任何背景颜色
android:background="#rrggbb"
为文本提供颜色
android:textcolor="#rrggbb"
您可以使用此页面以十六进制格式找到正确的RGB值
colorpicker
在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" />