Set colour to text in Android activity?

12,820

Solution 1

If you want it to set in XML layout then use:

<TextView 
 ...
 ...
 android:textColor="#FF0000" >
 </TextView>

If you want to set programmatically then use:

textview.setTextColor(Color.RED);
//textview must be defined in your class 

Solution 2

Read the docs for TextView, specifically for textColor.

Solution 3

Use the following in your xml where you want to change the color to red and by using the other hexacode of color you can change to any other color. This is an example to set the color to red:

android:textColor="#FF0000" 

Solution 4

Use this in your layout:

<TextView>
  ....
  textColor="red"
  ....
</TextView>

Solution 5

Create a custom style resource which uses an Android Theme as a parent then override the text colors as defined in the Android theme.xml. Reference this new style in your AndroidManifest.xml's application tag.

Share:
12,820
tiranodev
Author by

tiranodev

Updated on August 02, 2022

Comments

  • tiranodev
    tiranodev almost 2 years

    I would like to set a red colour text in my app, but I don't know how.

    Please provide references. Thanks.