Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Color of the text in TextView changes color

Tags:

android

In android, when I press on a TextView, the text changes color (from white to grey). Can you please tell me how can I disable that functionality?

Thank you.

like image 873
hap497 Avatar asked Feb 18 '10 18:02

hap497


People also ask

What attribute changes 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.

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 my text messages on Android?

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

Can we change the text in TextView?

TextView tv1 = (TextView)findViewById(R. id. textView1); tv1. setText("Hello"); setContentView(tv1);


1 Answers

The TextView gets its styling from whatever styles or themes you have set in your application. See android docs for an overview of those.

Part of the default theme is the look and feel of a widget in each of its states. A selector is used to configure the look and feel in a particular state, for example if it is enabled, or clicked.

To override the behavior you need to create a style (as described in the android doc above) and apply that style to your TextView.

like image 70
Cheryl Simon Avatar answered Sep 20 '22 22:09

Cheryl Simon