Android按钮在应用主题后看起来很奇怪
问题描述:
我在将按钮应用到主题时出现问题。不使用主题一切都看起来不错,你可以在这个截图中看到: http://i47.tinypic.com/2czyctv.jpgAndroid按钮在应用主题后看起来很奇怪
后我申请我的主题,它看起来是这样的: http://i48.tinypic.com/w03s6x.png
颜色是好的,但按钮的高度错误,上面的按钮和水平线之间的空间也消失了。实际上主题按钮应该看起来像他们的大小非模仿按钮,因为我唯一想改变的是颜色。
值/的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>
绘制/ 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>
绘制/ 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>
我希望S.O.可以帮我。并对不起我的英语不好......
答
您的按钮填充用于在9补丁背景中声明,GradientDrawable不会为您做。您需要为主题添加android:padding属性或使用9修补程序。