The default dividing line of ListView in android is to fill the width of the entire listview, and then the designer needs to be in a state that is not filled, find relevant information, and write a demo to verify.
Of course, the easiest way to implement it is to use a picture, but the picture needs to be related to the resolution, so it will be more direct to fill it with color.
Define the divider line I need in the drawable main_list_divider_line.xml
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:left="10dp" android:right="10dp"> <shape android:shape="rectangle" > <solid android:color="#33000000" /> </shape> </item> </layer-list>
Among them, android:left indicates the distance from the left, android:right indicates the distance from the right, android:shape="rectangle" indicates that it is filled with a rectangle, and android:color="#33000000" fills the color.
Then set the dividing line as the above filler in the place where the listview is configured
<ListView
android:id="@+id/main_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@drawable/main_list_divider_line"
android:dividerHeight="1px"
android:layout_marginTop="14dp" >
</ListView>