記錄一下
方案來源于:騎馬倚斜橋w的簡書文章
shape 能畫實線跷叉、虛線,都是橫線营搅。要變成豎線云挟,需要旋轉(zhuǎn)。
注意:如果是實線豎線转质,不用 shape 實現(xiàn)更快园欣。
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:left="-300dp"
android:right="-300dp">
<rotate
android:fromDegrees="90"
android:visible="true">
<shape android:shape="line">
<stroke
android:width="1dp"
android:color="@color/sale_stage_complete_color"
android:dashGap="2dp"
android:dashWidth="6dp"/>
</shape>
</rotate>
</item>
</layer-list>
<View
android:id="@+id/viewLine"
android:layout_width="0.5dp"
android:layout_height="80dp"
android:layerType="software"
android:background="@drawable/shape_sale_stage_select_line"/>
1、dashwidth是指- - -中每一個-的寬度休蟹,dashGap是指- - -中每一個間隔的寬度沸枯,如果dashwidth和dashGap中有一個為0,那么這條線就是一條實線赂弓。width是指這條線的寬度绑榴,在橫的虛線上體現(xiàn)出來就是這條線的豎直方向的高度。
2拣展、把這個drawable作為一個view的背景時彭沼,需要設(shè)置view的layerType為software,不然在真機上顯示出來是一條實線备埃。
3姓惑、作為背景的view的layout_height要超過drawble的stroke的width,不然顯示不出來按脚。