Android--listView的divider分割线样式和边距

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>

 

posted @ 2016-01-13 22:12  灬布衣丶公爵丨  阅读(2094)  评论(0编辑  收藏  举报