android – 将buttonStyle作为主题应用不起作用,但如果直接应用于按钮则会起作用

我正在关注 creating custom buttons的教程.如果我直接将该样式应用于按钮,它可以工作,但是如果我使用android:buttonStyle将样式应用于主题则不起作用.

示例 – 以下是应用了按钮样式的样式xml:
价值观/ styles.xml

<resources>
    <style name="MyTheme" parent="android:Theme.Light">
       <!-- the button gets styled but is no longer clickable 
            if i do it like this -->
       <item name="android:buttonStyle">@style/ButtonText</item>
    </style>

    <style name="ButtonText">
        <item name="android:layout_width">fill_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:textColor">#ffffff</item>
        <item name="android:background">@drawable/ruddy_orange_button</item>
    </style>
</resources>

绘制/ ruddy_orange_button.xml:

<item android:state_pressed="true">
        <shape>
            <solid android:color="#70c656" />
            <stroke android:width="1dp" android:color="#53933f" />
            <corners android:radius="3dp" />
            <padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" />
        </shape>
    </item>
   <item>
        <shape>
            <gradient android:angle="270" android:endColor="#fd4d4d" android:startColor="#f24b4b" />
            <stroke android:width="1dp" android:color="#f04a4a" />
            <corners android:radius="4dp" />
            <padding android:bottom="10dp" android:left="10dp" android:right="10dp" android:top="10dp" />
        </shape> 
    </item>
</selector>

但是,如果我将样式直接应用于按钮,它可以工作:

<Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    style="@style/ButtonText"
    android:text="hello there" />

关于我在这里做错了什么的指示?

我在Android 2.3.3上测试了这个

来源于github.

解决方法

试试这个:
<style name="ButtonText" parent="@android:style/Widget.Button">

相关文章

这篇“android轻量级无侵入式管理数据库自动升级组件怎么实现...
今天小编给大家分享一下Android实现自定义圆形进度条的常用方...
这篇文章主要讲解了“Android如何解决字符对齐问题”,文中的...
这篇文章主要介绍“Android岛屿数量算法怎么使用”的相关知识...
本篇内容主要讲解“Android如何开发MQTT协议的模型及通信”,...
本文小编为大家详细介绍“Android数据压缩的方法是什么”,内...