2011-01-19 66 views
15

我想要做的是定義一個在LinearLayout中使用的共同背景,該背景使我的應用程序在其許多活動中經常出現。此特定佈局是顯示在每個活動頂部的標題。我可以在一個Android drawable中使用多個形狀嗎?

我想要做的是創建一個drawable,用漸變填充linearlayout並在梯度下面有一條水平線。

有誰知道這是可能的還是我必須做這種事情只與嵌套佈局。

我attemptat提拉XML是

<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
<item> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 
    <gradient android:startColor="#AA000000" android:endColor="#AA333333" 
     android:angle="270" /> 
</shape> 
</item> 
<item> 
<shape android:shape="line"> 
    <stroke android:width="3dp" android:color="#FFFFFFFF" 
      android:dashWidth="1dp" android:dashGap="2dp" /> 
    <size android:height="5dp" /> 
</shape> 
</item> 
</selector> 

回答

30

繪製對象接受多個形狀,(在其他文件中總是被定義),如果我明白你的問題,也許你可以做一個圖層繪製(這借鑑了頂部的多個潛在的可繪彼此)

我在這裏寫這個,所以,我沒有測試,但試試這個,並閱讀這個奇妙的文檔。

<?xml version="1.0" encoding="utf-8"?> 
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
     <item android:drawable="@drawable/shape_7"/> 
     <item android:drawable="@drawable/shape_1"/> 
    </layer-list> 

the android complete xml resources

歡呼

+25

是否也可以將它們設置一個低於其他(Y座標)? – 2013-05-21 13:39:12

相關問題