Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wrong Button textColor and drawablePadding on pre-Lollipop using Appcompat

I have wrong button style on pre-Lollipop devices.

compiling using appcompat library.

compile 'com.android.support:appcompat-v7:23.0.1'

values/styles.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="colorPrimary">@android:color/holo_orange_light</item>
    <item name="colorPrimaryDark">@android:color/holo_orange_dark</item>
    <item name="colorAccent">@android:color/holo_green_light</item>

    <item name="colorControlNormal">@android:color/holo_purple</item>
    <item name="colorControlHighlight">@android:color/holo_red_light</item>
    <item name="colorButtonNormal">@android:color/holo_green_light</item>

    <item name="android:buttonStyle">@style/ButtonTheme</item>

</style>

<style name="ButtonTheme" parent="android:Widget.Button">
    <item name="android:textColor">@android:color/white</item>
    <item name="android:textAllCaps">true</item>
    <item name="android:drawablePadding">10dp</item>
    <item name="android:padding">10dp</item>
</style>

v21/styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="ButtonTheme" parent="android:Widget.Material.Button">
        <item name="android:textColor">@android:color/white</item>
        <item name="android:textAllCaps">true</item>
        <item name="android:drawablePadding">10dp</item>
        <item name="android:padding">10dp</item>
    </style>
</resources>

The result is http://prntscr.com/8mt1jx

"New button" adding by xml on ISC has no style textColor and drawablePadding. Do you have any ideas to correct it?

like image 265
Georg Avatar asked Mar 14 '23 14:03

Georg


1 Answers

The problem is the buttonStyle in your normal styles.xml.

Replace

<item name="android:buttonStyle">@style/ButtonTheme</item>

With

<item name="buttonStyle">@style/ButtonTheme</item>

And it should work.

like image 122
Bas van Stein Avatar answered Apr 26 '23 07:04

Bas van Stein