Android Coding

How to change the global button text color of an app on Android?

2 views September 21, 2018 September 21, 2018 bicobro 0

To change the default text color of the buttons in your app so that the button text color in your app is the same everywhere, do the following:

  1. Go to /res/values/colors.xml
  2. Add the color to the colors.xml if not available as shown below
  3. Go to /res/values/styles.xml
  4. Add a new style and link it to the android:textAppearanceButton item style to the theme as shown below. Additionally, you can add button textSize.

colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    ...
    <color name="button_text_color">#AAAAAA</color>
    ...
</resources>

styles.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light">
        ...
        <item name="android:textAppearanceButton">@style/ButtonText</item>
        ...
    </style>

    <style name="ButtonText">
        <item name="android:textColor">@color/button_text_color</item>
        <item name="android:textSize">16sp</item>
    </style>

Was this helpful?