0

我想要兩個白色的線 - 一個在視圖的頂部,另一個在 底部的視圖!自定義形狀可繪製的android(線只在視圖上方和下方)

沒有左右邊框!!!!!

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <solid android:color="#00000000"/> 
    <stroke android:width="0.1dp" android:color="#FFFFFF" /> 
    <corners android:radius="5dp"/> 
    <padding android:left="5dp" android:top="5dp" android:right="5dp" android:bottom="5dp" /> 
</shape> 

我得到一個帶有白色邊框和透明背景的矩形形狀的視圖。

但我只想要矩形的頂部和底部線條,而不是左右矩形的線條。

我想要一個邊框只在頂部和底部的視圖,看起來像夾在兩條細線之間?

+2

[有底衝程機器人形狀]的可能的複製(http://stackoverflow.com/questions/19238738/android-shape-with-bottom-stroke) – 0X0nosugar

+0

0X0nosugar是賴特,沒有自然形狀與單筆畫線,你必須做一些layerList佈局.... – Opiatefuchs

回答

0

嘗試使用<layer-list>。檢查此下面

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

    <!-- Border --> 
    <item> 
     <shape android:shape="rectangle"> 
      <solid android:color="COLOR_OF_BORDER" /> 
     </shape> 
    </item> 

    <!-- Rest of the drawable --> 
    <item> 
     <shape android:shape="rectangle"> 
      <solid android:color="COLOR_OF_REST" /> 
      <padding 
       android:bottom="2dp" 
       android:top="2dp" /> 
     </shape> 
    </item> 

</layer-list> 
相關問題