I have a problem applying a theme to my buttons. without using the theme everything looks fine as you can see on this screenshot:
http://i47.tinypic.com/2czyctv.jpg
after I have applied my theme it looks like this:
http://i48.tinypic.com/w03s6x.png
the color is fine, but the height of the button is wrong and also the space between the upper button and the horizontal line disappeared. actually the themed buttons should look like the unthemed buttons for their size because the only thing i wanted to change was the color.
values/themes.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.KIT.Styled" parent="Theme.Sherlock.Light.DarkActionBar">
<item name="actionBarStyle">@style/ActionBar</item>
<item name="android:actionBarStyle">@style/ActionBar</item>
<item name="android:buttonStyle">@style/Button</item>
</style>
<style name="ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
<item name="background">@drawable/actionbar_background_shape</item>
<item name="android:background">@drawable/actionbar_background_shape</item>
</style>
<style name="Button" parent="@android:style/Widget.Button">
<item name="android:background">@drawable/kit_button</item>
</style>
</resources>
drawable/kit_button.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_enabled="false"
android:drawable="@drawable/kit_button_background_shape" />
<item
android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/kit_button_background_shape" />
<item
android:state_focused="true"
android:state_enabled="true"
android:drawable="@drawable/kit_button_background_shape" />
<item
android:state_enabled="true"
android:drawable="@drawable/kit_button_background_shape" />
</selector>
drawable/kit_button_background_shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<gradient
android:startColor="@color/KIT_GREEN"
android:endColor="@color/KIT_GREEN_LIGHT"
android:angle="90"
android:centerX="0.5"
android:centerY="0.5" />
</shape>
i hope s.o. can help me. and sorry for my bad english…
Your buttons padding used to be declared within the 9-patch background, a GradientDrawable doesn’t do that for you. You need to add a android:padding attribute to your theme or use a 9-patch.