在开发过程中,使用listView假如有很多数据,要实现快速滚动的话,该怎么实现呢?其实很简单。只需要布局的xml文件里设置属性即可:
android:fastScrollEnabled="true"
android:focusable="true"
但是有时候会发现设置属性无效,滚动ListView并未出现滑块。原因是该属性生效有最小记录限制。当ListView记录能够在4屏以内显示(也就是说滚动4页)就不会出现滑块。可能是api设计者认为这么少的记录不需要快速滚动。

我的依据是android源代码,见FastScroller的常量声明:

// Minimum number of pages to justify showing a fast scroll thumb
private static int MIN_PAGES = 4;


以及:

// Are there enough pages to require fast scroll? Recompute only if total count changes
if (mItemCount != totalItemCount && visibleItemCount > 0) {
mItemCount = totalItemCount;
mLongList = mItemCount / visibleItemCount >= MIN_PAGES;
}

更多相关文章

  1. 如何使Android应用程序获取系统权限
  2. android:layout_weight属性详解
  3. android layout 研究
  4. Android(安卓)activity属性设置大全
  5. Android属性动画优化(更高效的使用属性动画)
  6. Android(安卓)Intent个人介绍
  7. Android(安卓)- menu 相关
  8. Android(安卓)布局 之 LinearLayout
  9. Android矢量动画-VectorDrawable

随机推荐

  1. Android(安卓)通知(使用NotificationCompa
  2. Android进程系列第八篇---LowmemoryKille
  3. Android系统利用tcpdump抓包
  4. Android开发者指南(29) ―― USB Host an
  5. Android(安卓)调用系统相机拍照保存以及
  6. Android使用AccessibilityService实现USB
  7. 即将到来的Android(安卓)N,将具备这些新特
  8. Fast File Transfer – 让 Android 通过
  9. Android/IOS手机使用Fiddler抓包
  10. Android测试驱动开发实践1