Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change default color in all texts in my Android application?

I would like to change all color texts in my application. So I wrote this code and I set my theme in the manifest:

<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
    <item name="android:textColor">@color/white</item>
</style>

But only TextView texts are in white. I would like Button and EditText to be in white too.

Can anyone help me? Thank you in advance.

like image 301
M07 Avatar asked Oct 30 '12 15:10

M07


People also ask

How do you color text on Android?

In XML, we can set a text color by the textColor attribute, like android:textColor="#FF0000" .


2 Answers

Your Theme:

 <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
     <item name="android:textColor">@color/white</item>
     <item name="android:buttonStyle">@style/ButtonTheme</item>
  </style>

And this is how you can set your Button Theme:

<style name="ButtonTheme" parent="android:style/Widget.Button">
     <item name="android:textColor">@color/white</item>
</style>

And also do this with EditTexts etc.

like image 62
Ahmad Avatar answered Sep 24 '22 06:09

Ahmad


I think most of the widget styles build off of these:

    <item name="android:textColorPrimary">@android:color/primary_text_dark</item>
    <item name="android:textColorSecondary">@android:color/secondary_text_dark</item>
    <item name="android:textColorTertiary">@android:color/tertiary_text_dark</item>
    <item name="android:textColorPrimaryInverse">@android:color/primary_text_light</item>
    <item name="android:textColorSecondaryInverse">@android:color/secondary_text_light</item>
    <item name="android:textColorTertiaryInverse">@android:color/tertiary_text_light</item>
    <item name="android:textColorPrimaryDisableOnly">@android:color/primary_text_dark_disable_only</item>
    <item name="android:textColorPrimaryInverseDisableOnly">@android:color/primary_text_light_disable_only</item>
    <item name="android:textColorPrimaryNoDisable">@android:color/primary_text_dark_nodisable</item>
    <item name="android:textColorSecondaryNoDisable">@android:color/secondary_text_dark_nodisable</item>
    <item name="android:textColorPrimaryInverseNoDisable">@android:color/primary_text_light_nodisable</item>
    <item name="android:textColorSecondaryInverseNoDisable">@android:color/secondary_text_light_nodisable</item>
    <item name="android:textColorHint">@android:color/hint_foreground_dark</item>
    <item name="android:textColorHintInverse">@android:color/hint_foreground_light</item>
    <item name="android:textColorSearchUrl">@android:color/search_url_text</item>

Override the values as needed.

like image 36
jsmith Avatar answered Sep 23 '22 06:09

jsmith