https://kotlinlang.org logo
#kotlin-in-action
Title
# kotlin-in-action
k

KV

09/14/2020, 8:01 AM
Hello guys, I have a question related to "how to set the textcolor for all the textview inside the constraint layout at once?" Example: I have 10 textviews inside constraint layout. And based on some condition I have to change all the textview's textcolor. Rather than add textView1.setTextColor, textView2.setTextColor....textview10.setTextColor() ...do we have any other way to handle this ? Thanks in advance 🙂
a

Anastasia Finogenova

11/06/2021, 4:47 AM
It is pretty trivial if you are using data binding. Create a live data that holds the color res id and then use binding to bind the text views to it so you change the value of live data and the view redraw
16 Views