Reputation: 2205
I want to change the look (Style) of various views dynamically in an Activity. But on going through various blogs, I came to know that android does not support dynamically setting styles for Views programmatic / dynamic., though I am not sure.
1) Is there any other ways of implementing apart from making use THEMES or making use layout xml files having styles pre set ?
2) Is it possible to set the different styles for various views (say green colour text for TextView1 and red color text for TextView2) by making use of setTheme() for entire Activity?
Thanks
Upvotes: 1
Views: 397
Reputation:
Use this xml file in as resource and add it in drawable folder.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:angle="90"
android:centerColor="#f77b2d"
android:endColor="#f99f66"
android:startColor="#f66a11" />
<stroke
android:width="0.5dp"
android:color="#313437" />
<corners
android:bottomLeftRadius="4dp"
android:bottomRightRadius="4dp"
android:topLeftRadius="4dp"
android:topRightRadius="4dp" />
</shape>
Upvotes: 1
Reputation:
You can change the text color in your java file like this.
textview1.setTextColor(Color.GREEN);
textview2.setTextColor(Color.RED);
Upvotes: 1