2014-10-31 217 views
0

我有這個繪製一個矩形。Android形狀自定義矩形

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:shape="rectangle"> 
    <solid android:color="#00000000" /> 
    <stroke android:width="1dp" android:color="#ffffff" android:dashWidth="0dp" android:dashGap="0dp" /> 
</shape> 

但我只想在頂部和底部兩條水平線。我們如何實現這一目標?

Iwant to achieve no 2

回答

0

我得到線索從這個Open-sided Android stroke?

它現在。

<?xml version="1.0" encoding="UTF-8"?> 
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 
<!-- This is the line --> 
    <item android:top="-1dp" android:right="-1dp" android:left="-1dp"> 
     <shape> 
      <solid android:color="@android:color/transparent" /> 
      <stroke android:width="1dp" android:color="#ffffff" /> 
     </shape> 
    </item> 

    <item android:bottom="-1dp" android:right="-1dp" android:left="-1dp"> 
     <shape> 
      <solid android:color="@android:color/transparent" /> 
      <stroke android:width="1dp" android:color="#ffffff" /> 
     </shape> 
    </item>  
</layer-list>