Is there a way to set the text alignment property for all TextViews across the application in Android without actually having to make changes to each TextView individually?
The project is quite large and it is not feasible to modify every single TextView.
Create a styles.xml
:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme" parent="android:Theme">
<item name="android:textViewStyle">@style/MyTextViewStyle</item>
</style>
<style name="MyTextViewStyle"
parent="android:Widget.TextView">
<item name="android:textColor">#F00</item>
<item name="android:textStyle">bold</item>
</style>
</resources>
Then just apply that theme to your application in AndroidManifest.xml
:
<application […] android:theme="@style/MyTheme">…
And all your text views will default to the style defined in MyTextViewStyle
(in this instance, bold and red)!
This was tested on devices from API level 4 onward and seems to work great.