Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you set a default textColor inside a LinearLayout that contains multiple TextViews?

I have a LinearLayout with that has multiple TextViews and want to set up a default global color for that layout only without having to add a textColor field inside each TextView. Also, if it's possible, would it also be possible to override the color value by adding it inside the TextView? i.e. If I set blue as a default color and black for a single TextView, would the blue change to black?

like image 893
student Avatar asked Oct 22 '25 01:10

student


1 Answers

You can override default text colors for the entire application by setting textColorPrimary and textColorSecondary in your parent in styles.xml

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="textColorPrimary">@color/black</item>
    <item name="textColorSecondary">@color/grey</item>
</style>

like image 154
Joseph Cobbinah Avatar answered Oct 24 '25 14:10

Joseph Cobbinah



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!