creating custom buttonsのチュートリアルに従っていました。スタイルをボタンに直接適用すると、それは機能しますが、android:buttonStyle
を使用してスタイルをテーマに適用すると機能しません。 -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" />
私がここで間違っていることを指摘してください。
私は
ソースがgithub上でのAndroid 2.3.3でこれをテストしました。