I have following textview in my Activity. I want to change the background color of the textview dynamically.
My problem is I don't want to get the colors from Resouce file or other colors.RED method. I'm getting colors from webservie in websafe mode (i.e #FFF, #000 etc).
How can I pass these colors as background to TextView. Thanks in advance for your time.
<TextView
android:id="@+id/colorCode"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" android:background="#FF0000" android:layout_marginRight="5dp"/>
Below is snippet might help you where txtChannelName
is an object of TextView
txtChannelName.setBackgroundColor(Color.RED);
or
txtChannelName.setBackgroundColor(Color.parseColor("#ffffff"));
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