1、建立一个drawable文件list_divider.xml
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:left="16dp" android:right="16dp"> <shape android:shape="rectangle" > <solid android:color="#ffdddddd" /> </shape> </item> </layer-list>
2、设置listView的divider的样式
<ListView android:id="@+id/ptrl_newslist_main" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ffffff" android:scrollbars="vertical" android:divider="@drawable/list_divider" android:dividerHeight="0.5dp">//必须带上,否则不显示 </ListView>
Android--listView的divider分割线样式和边距
原文:http://www.cnblogs.com/819158327fan/p/5128712.html