I encountered a scenario where I needed to customize the splitter line of the ListView, which was made up of two lines, and it was difficult to use XML drawable.
Note: Draw two lines is to achieve the effect of the sunken, in the drawing of a dark line followed by a clearly will give a person visually obvious "ditch" feeling.
Because my background is transparent (background gradient), directly with the picture to achieve the effect is not good.
Look at the effect:
Use Layer-list to implement.
Layer-list can contain multiple item, each item is stacked together.
The layer-list item can be spaced and implemented using properties such as Android:bottom.
Specific practices:
1. Draw the first line first.
2. The second line sets the spacing, 1px from the head, so it does not overlap completely
3. Two lines stacked together
The specific code is as follows.
<?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></la Yer-list>
Reference: Http://stackoverflow.com/questions/14436641/understanding-androids-layer-list
Android Development (33) Customizing the split Line of the ListView (draw multiple lines with XML drawable)