Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get text color of TextView?

Tags:

android

In given code lbl[0].getTextColor() is giving Error but i don't know how to get text color of textview in java file please help me.

public void angry(View v) {     if (lbl[0].getTextColor() == Color.BLACK)         lbl[0].setTextColor(Color.RED);     if (lbl[0].getTextColor() == Color.RED)         lbl[0].setTextColor(Color.BLACK); }    

Thanks.

like image 418
Jignesh Ansodariya Avatar asked Jul 19 '11 10:07

Jignesh Ansodariya


People also ask

Which property is used to color text in TextView in android?

In XML, we can set a text color by the textColor attribute, like android:textColor="#FF0000" .

How do I change the color of TextView?

TextView Text Color – To change the color of text in TextView, you can set the color in layout XML file using textColor attribute or change the color dynamically in Kotlin file using setTextColor() method.

How do I change the text color on my android?

Open your device's Settings app . Text and display. Select Color correction. Turn on Use color correction.


1 Answers

Use this

textView.getCurrentTextColor()

like image 70
JeffG Avatar answered Sep 24 '22 21:09

JeffG