如何在Android上使用XML指定RGB格式颜色

use*_*627 7 android android-layout

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

Nik*_*hil 19

您可以在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" />
Run Code Online (Sandbox Code Playgroud)

一般形式:

android:textColor="#332116" is "#rrggbb"
Run Code Online (Sandbox Code Playgroud)

  • 谢谢迈克尔但是假设我的rgb值为147,112,219.我该如何指定它? (3认同)