原理:自制的分割线替换掉系统默认的分割线
1.在drawable里面创建xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <gradient android:startColor="#ffff0000"//开始的颜色 android:centerColor="#ff00ff00"//中间的额颜色 android:endColor="#ff0000ff"//结束的颜色 android:type="linear" /> <size android:height="4dp"/>//分割线的高度为4dp </shape>2.在values下的styles.xml里重新定义
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> //将drawable 的分割线替换掉默认的分割线 <item name="android:listDivider">@drawable/fgx</item> </style> </resources>