在Android活动中将颜色设置为文字?

tir*_*dev 2 android text colors

我想在我的应用程序中设置一个红色文本,但我不知道如何.

请提供参考.谢谢.

Viv*_*kur 7

如果要在XML布局中设置它,请使用:

<TextView 
 ...
 ...
 android:textColor="#FF0000" >
 </TextView>
Run Code Online (Sandbox Code Playgroud)

如果要以编程方式设置,请使用:

textview.setTextColor(Color.RED);
//textview must be defined in your class 
Run Code Online (Sandbox Code Playgroud)