How to specify RGB color using XML on Android

Please give an example of specifying RGB color using XML on Android. Syntax #rrggbb .

+7
source share
2 answers

You can specify an RGB color in XML as follows:

 <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" /> 

General form:

 android:textColor="#332116" is "#rrggbb" 
+17
source

To provide any background color

 android:background="#rrggbb" 

To provide text color

 android:textcolor="#rrggbb" 

You can use this page to find out the correct RGB value in hexadecimal format.

Colorpicker

To specify comments in 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" /> 
+3
source

All Articles