Android快速滚动
16lz
2021-12-04
在开发过程中,使用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;
}
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;
}
更多相关文章
- 如何使Android应用程序获取系统权限
- android:layout_weight属性详解
- android layout 研究
- Android(安卓)activity属性设置大全
- Android属性动画优化(更高效的使用属性动画)
- Android(安卓)Intent个人介绍
- Android(安卓)- menu 相关
- Android(安卓)布局 之 LinearLayout
- Android矢量动画-VectorDrawable