I am using Android Studio 2.2.1 with project with these settings:
compileSdkVersion 24
buildToolsVersion "24.0.2"
minSdkVersion 16
targetSdkVersion 24
If I use the GUI to change the button background, it adds this to the layout:
android:background="@color/colorPrimary"
Then, if I run the app on a 4.4 virtual device (Microsoft's Android Emulator because I'm on an AMD system and I want a fast emulator), or on a Samsung Galaxy S6 with Android 6.0.1, the button has the correct color but loses left and right padding and the text runs right to the left and right edge of the button.
If I set only the backgroundTint, then the button has the correct padding on the virtual device, but not the correct color. However, on the S6, it has the correct color and padding.
This seems like a bug somewhere, but where? Is it in the code generation or is this a bug in Android 4.4?
I think Android Studio should be doing whatever needed to make it work correct on both platform levels, whether it is as complex as some of these solutions:
Standard Android Button with a different color
or something more succinct.
My styles.xml file shows:
<resources>
<!-- 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>
</style>
</resources>
and my AndroidManifest theme setting is:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"