2013-10-19 222 views
0

嗨,我想在ActionBarSherlock上設置漸變背景我目前在主題中設置此爲可繪製的形狀,但是當我運行它時它只是有一個白色背景沒有人知道我是什麼做錯了或如何做到這一點?ActionBarSherlock設置漸變背景

繼承人我的風格(我已經在清單文件中聲明這一點)

<style name="MyTheme.ActionBarStyle" parent="Widget.Sherlock.ActionBar"> 

    <item name="background">@drawable/bg_actionbar</item> 
    <item name="android:background">@drawable/bg_actionbar</item> 
</style> 

<style name="Theme.SherlockCustom" parent="@style/Theme.Sherlock.Light"> 
    <item name="actionBarStyle">@style/MyTheme.ActionBarStyle</item> 

</style> 

和我的繼承人繪製

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle"> 
    <gradient 
    android:type="radial" 
    android:gradientRadius="400" 
    android:startColor="#FF0000" 
    android:endColor="#0000FF" /> 
</shape> 

回答

0

一切都很酷唯一的XML梯度元素應該是這樣的:

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle"> 
    <gradient 
    android:angle="270" 
    android:startColor= "#FF0000" 
    android:centerColor="#FF0000" 
    android:endColor="#0000FF" /> 
</shape>