listView 相关的优化设置

 
android:divider="#FF0000" 定义分隔符为红色android:dividerHeight="6px" 定义分割符的高度
Item之间无间隙:在xml文件中ListView控件中加入如下属性:android:divider="#00000000"或者在javaCode中如下定义:listView.setDividerHeight(0);
自定义的BaseAdapter中调用notifyDataSetChanged()方法会重新调用BaseAdapter的getView()方法。

 点击Item时无背景颜色变化:在xml文件中的ListView控件中加入如下属性:android:listSelector="@drawable/timer_list_selector"


  在drawable中定义timer_list_selector的属性值
  timer_list_selector.xml中定义如下:
  <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
        <item android:state_selected="true" android:drawable="@android:color/transparent" />
  </selector>

<ListView
        android:id="@+id/listview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
//listview拖动时背景变黑的问题 android:cacheColorHint="@color/transparent" //上下的阴影 android:fadingEdge="none" />

//设置快速滑块

android:fastScrollEnabled="true"
但是有时候会发现设置属性无效,滚动ListView并未出现滑块。原因是该属性生效有最小记录限制。当ListView记录能够在4屏以内显示(也就是说滚动4页)就不会出现滑块。

如果想自定义滑块属性,可以采用反射机制,获取滑块对象设置。

原文地址:https://www.cnblogs.com/lipeil/p/2645443.html