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.
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.
In XML, we can set a text color by the textColor attribute, like android:textColor="#FF0000" .
Open your device's Settings app . Text and display. Select Color correction. Turn on Use color correction.
TextView tv1 = (TextView)findViewById(R. id. textView1); tv1. setText("Hello"); setContentView(tv1);
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With