demand

I need to customize the listView splitter, which is made up of two lines, and I’m having trouble using XML drawable.

Two lines are drawn to achieve the effect of depressions, and a dark line followed by an obvious one in the drawing gives the visual impression of a distinct “trench”. Since my background is transparent (gradient background), using images directly doesn’t look good.

Effect:

Train of thought

Use layer-list to do this. Layer-list can contain multiple items, each stacked on top of the other. Layer-list items can set spacing, using properties like Android :bottom.

Specific practices:

1. Draw the first line. 2. Set the second line 1px apart from the head so that it does not overlap completely 3. The two wires are stacked on top of each other

The specific code is as follows

<? The XML version = "1.0" encoding = "utf-8"? > <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:bottom="0px" android:left="0px"  android:right="0px" android:top="0px"> <shape android:shape="rectangle" > <size android:height="1px" android:width="1px" /> <solid android:color="#A18249" /> </shape> </item> <item android:bottom="0px" android:left="0px" android:right="0px" android:top="3px"> <shape android:shape="rectangle" > <size android:height="2px" android:width="2px"  /> <solid android:color="@android:color/white" /> </shape> </item> </layer-list>Copy the code

reference

Stackoverflow.com/questions/1…