Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextColor vs TextColorPrimary vs TextColorSecondary

What do each of these encompass in terms of text throughout an app?

More specifically, what would changing each of these in a theme change throughout my app? I'd like my buttons' texts to be a different color than my textviews; is one primary and the other secondary?

Any info related to these terms is appreciated!

like image 259
rafvasq Avatar asked Aug 22 '16 00:08

rafvasq


1 Answers

TextColor is just the xml attribute to set a color to the text of any given view.

TextColorPrimary is the default text color for enabled buttons and Large Textviews.

TextColorSecondary is the default text color for Medium and Small Textviews.

Ignore this, as for what you want to do, there is a better way. You want to edit your style.xml such that the default theme AppTheme (or whatever else you have declared as your theme in your manifest) contains the necessary xml attributes to customize your text colors.

The resulting AppTheme style will look like this when youre done.

<!-- 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="android:textColor">#hexColorForTextViews</item>
    <item name="android:buttonStyle">@style/myDefaultButton</item>
</style>

textColor will set the default color for all of your textviews. buttonStyle will reference a custom style that you want for all of your buttons. To make this work, add this style tag to your styles.xml file.

<style name="myDefaultButton">
    <item name="android:textColor">#hexColorForButtons</item>
    <!-- other stuff you want your buttons to inherit by default -->
</style>
like image 139
Ryan Pierce Avatar answered Sep 19 '22 06:09

Ryan Pierce