Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set `app:backgroundTint` for Textview programatically?

I am trying to add tint to my normal Textview not AppCompatTextView. I can add backgroundTint in xml using app:backgroundTint for it. Is there a way to do the same programatically for Textview itself.(I am targeting kitkat support)

Note: I have more Textview. so changing all of them will be over work

setSupportButtonTintListonly works for AppCompat controls. setBackgroundTintList shows no result in kitkat

like image 869
jafarbtech Avatar asked Aug 31 '26 13:08

jafarbtech


2 Answers

This works for me

someTextView.getBackground().setTint(yourIntColor);
like image 118
Martin Olariaga Avatar answered Sep 03 '26 03:09

Martin Olariaga


Note

Added in version 23.1.1 So you can't use in 19

For AppCompat , You can use setSupportButtonTintList

void setSupportButtonTintList (ColorStateList tint)

tvOBJ.setSupportButtonTintList(ContextCompat.getColorStateList(CurrentActivity.this, R.color.your_color));
like image 22
IntelliJ Amiya Avatar answered Sep 03 '26 02:09

IntelliJ Amiya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!