我想改变ListView分隔线的颜色。 任何帮助,将不胜感激。
#1楼
对于单色线使用:
list.setDivider(new ColorDrawable(0x99F10529)); //0xAARRGGBB
list.setDividerHeight(1);
重要的是DividerHeight设置在分隔符之后 ,否则你将得不到任何东西。
#2楼
您还可以使用以下方法从资源中获取颜色:
dateView.setDivider(new ColorDrawable(_context.getResources().getColor(R.color.textlight)));
dateView.setDividerHeight(1);
#3楼
对于ListView,使用android:divider="#FF0000"和android:dividerHeight="2px" 。
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="#0099FF"
android:dividerHeight="2px"/>
#4楼
适用于@Asher Aslan的XML版酷炫效果。
android:angle="180"
android:startColor="#00000000"
android:centerColor="#FFFF0000"
android:endColor="#00000000"/>
该形状的名称为:drawable文件夹下的list_driver.xml
android:id="@+id/category_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="@drawable/list_driver"
android:dividerHeight="5sp" />
#5楼
您可以使用android:divider="#FF0000"在布局xml文件中设置此值。 如果要更改颜色/可绘制,则还必须设置/重置分隔符的高度。
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:id="@+id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:divider="#FFCC00"
android:dividerHeight="4px"/>