Domanda

Like the title indicates, when setting background of a button via theme, the button stops responding. I believe it is an issue on a few android versions, since my Nexus 4 running KitKat has no issue, however my HTC Desire S running 2.3.5 has it happenning. By the way, I am using the HoloEverywhere 2.0 atm. What is the problem?

The way I set the theme is the following:

<style name="AppTheme" parent="@style/Holo.Theme.Light.DarkActionBar">
    <item name="android:buttonStyle">@style/MyButtonStyle</item>
</style>

The button style is the following:

<style name="MyButtonStyle" parent="android:style/Widget.Holo.Light.Button">
    <item name="android:background">@drawable/button_yellow</item>
</style>

This works on the N4, but will NOT work on the HTC Desire S. However, if I set the same background directly on the button, it is working well on the HTC too, like this:

<Button
    android:id="@+id/example_button"
    android:text="Example"
    android:gravity="center"
    android:onClick="onClickEvent"
    android:background="@drawable/button_yellow"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

Any idea what is going wrong?

È stato utile?

Soluzione

You should use Holo.Button.Light as parent in your custom button style.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top