2014-01-26 17 views
0

我想創建與下面的說明書一個XML矩形形狀XML形狀:的Android - 與特定筆劃

衝程/邊界頂= 0 DP
衝程/邊界左= 3 DP
衝程/邊界底部= 0 DP
中風/邊框右= 3 DP

我至今是:

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 

    <gradient android:type="linear" 
     android:angle="90" 
     android:startColor="#ff5588" 
     android:centerColor="#ff8855" 
     android:endColor="#ff5588" /> 

    <stroke android:width="3dp"/> <!-- the problem is here --> 
</shape> 

但正如您所知<stroke>標記不會爲我的目的提供任何相關選項。任何人都可以幫助我,我怎樣才能達到這種形狀。由於

回答

1

你可以嘗試使用layer-list象下面這樣:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item> 
     <shape android:shape="rectangle"> 
      <solid android:color="#THE_BORDER_COLOR"/> 
     </shape> 

    </item> 

    <item android:left="3dp" android:right="3dp"> 
     <shape 
      android:shape="rectangle"> 

      <gradient 
       android:type="linear" 
       android:angle="90" 
       android:startColor="#ff5588" 
       android:centerColor="#ff8855" 
       android:endColor="#ff5588"/> 
     </shape> 
    </item> 

</layer-list> 
+0

很不錯的解決方案!謝啦 –