[Android]ListView中分割线的设置

1.在布局文件中ListView元素中通过属性设置

[html] view plaincopy
 
  1. android:divider="#fffff"  分割线颜色  
  2. android:dividerHeight="1px"  分割线高度  

2.使用XML文件设置

[html] view plaincopy
 
  1. <!-- res/drawable/liner.xml ->  
  2. <?xmlversionxmlversion="1.0"encoding="utf-8"?>  
  3. <layer-list   xmlns:android="http://schemas.android.com/apk/res/android">  
  4.  <item>  
  5.    <shape>  
  6.       <gradient  
  7.          android:startColor="#000000"  
  8.          android:centerColor="#CCCCCC"  
  9.          android:endColor="#FFFFFF"  
  10.          android:height="1px"  
  11.          android:angle="0"/>  
  12.   </shape>  
  13.  </item>  
  14. </layer-list>  


在布局文件中引用

[html] view plaincopy
 
    1. <ListViewandroid:idListViewandroid:id="@id/android:list"  
    2.     ...  
    3.     android:divider="@drawable/list_divider"  
    4.     android:dividerHeight="1dip"  
    5.     />  
原文地址:https://www.cnblogs.com/mochaMM/p/5091694.html