Android Coding

How to change the button background color globally on Android?

1 views September 21, 2018 September 21, 2018 bicobro 0

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

  1. Go to /res/values/colors.xml
  2. Add the background color to the colors.xml if not available. See below.
  3. Go to /res/values/styles.xml
  4. Add the colorButtonNormal style item to the theme as shown below.

colors.xml

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

styles.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light">
        ...
        <item name="colorButtonNormal">@color/button_background</item>
        ...
    </style>

 

Was this helpful?