How to set text color in android app for all text?

Solution 1:

As was mentioned in denis.solonenko's answer, the correct approach would be to modify your theme.

Where you define your theme (in your themes.xml or styles.xml file), you'll want to add something like this:

<style name="AppTheme" parent="@style/Theme.AppCompat.Light">
    ...
    <item name="android:textColor">#FF00FF</item>
    ...
</style>

Then make sure that the theme is applied to your Activity or Application in the manifest:

<application
    ...
    android:theme="@style/AppTheme"
    .... 
    >

You can also define:

  • textColor - The default text color of any given view
  • textColorPrimary - The default text color for enabled buttons and Large Textviews
  • textColorSecondary - The default text color for Medium and Small Textviews
  • textColorTertiary - ?

(Source TextColor vs TextColorPrimary vs TextColorSecondary)

Keep in mind that many other things may override these predefined colors, such as applied styles or definitions in different resource folders.

See here for a full list of theme items: https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/themes.xml

Solution 2:

Create a custom theme for your app. Take look at the official guide.

Solution 3:

Yes you are right you can make that using style. Or you can use TextView.getTextColors().getDefaultColor() for set default text color. Actually I never used this but I think it may be help you.

For style

<style name="TextColor">
    <item name="android:textColor">#00FF00</item>
</style>      

Then in layout file

<TextView  style="@style/TextColor" />