2012-08-10 141 views
0

我在將按鈕應用到主題時出現問題。不使用主題一切都看起來不錯,你可以在這個截圖中看到: 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.可以幫我。並對不起我的英語不好......

回答

0

您的按鈕填充用於在9補丁背景中聲明,GradientDrawable不會爲您做。您需要爲主題添加android:padding屬性或使用9修補程序。

相關問題