首先layer-list可實(shí)現(xiàn)多個(gè)drawable疊加效果,每個(gè)drawable都寫(xiě)在item中以實(shí)現(xiàn)疊加球匕,item是按從下往上順序依次疊加。
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate
android:fromDegrees="135"
android:visible="true">
<shape android:shape="line">
<stroke
android:width="1dp"
android:color="@color/black" />
</shape>
</rotate>
</item>
<item>
<rotate
android:fromDegrees="45"
android:visible="true">
<shape android:shape="line">
<stroke
android:width="1dp"
android:color="@color/black"/>
</shape>
</rotate>
</item>
</layer-list>
主要是用兩個(gè)shape畫(huà)直線(xiàn),其中一條直線(xiàn)用rotate旋轉(zhuǎn)90度變?yōu)闄M線(xiàn)亚隅,以此形成加號(hào)圖像。
stroke的width表示直線(xiàn)的厚度庶溶。