Android 控制listview 滑动速度
2016-05-20 11:20
1026 查看
android 因为listview本身的滑动速度太快,我的界面的速度刷新太快,所以视觉上会看不清数据,需要控制listview的滑动速度,找到如下一篇文章:
大概的意思就是控制listview的滑动速度,可以使用ViewConfiguration里的一个getScrollFriction摩擦力属性,来增加摩擦系数,从而让滑动变慢,主要是依据://摩擦力,用来计算减速度 ViewConfiguration.getScrollFriction() mDeceleration = computeDeceleration(ViewConfiguration.getScrollFriction());
如下为原文和扩展:
How to control Android ListView scrolling speed
I found that I can control the scrolling speed of an Android ListViewusing
code like this in a
Fragment:
@Override public void onStart() { super.onStart(); // scroll speed decreases as friction increases. a value of 2 worked // well in an emulator; i need to test it on a real device getListView().setFriction(ViewConfiguration.getScrollFriction() * 2); }
I did this because the default
ListViewscroll
speed is too fast by default, and as a result, it’s hard on the eyes when you scroll through a lot of items.
简介: ViewConfiguration 是系统中关于视图的各种特性的常量记录对象。其中包含各种基础数据 |
ViewConfiguration中的值一般是在编写高级控件是才会用到。由于常量非常多,部分常量光看说明无法知道其真实作用,这是一个慢慢收集记录的过程,在实际运用中遇到新的常量我会慢慢添加。 //在可滑动的控件中用于区别单击子控件和滑动操作的一个伐值。 mTouchSlop = configuration.getScaledTouchSlop(); //用于设置最小加速率和最大速率 mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); //滚动距离 mOverscrollDistance = configuration.getScaledOverscrollDistance(); //fling距离 mOverflingDistance = configuration.getScaledOverflingDistance(); //摩擦力,用来计算减速度 ViewConfiguration.getScrollFriction() mDeceleration = computeDeceleration(ViewConfiguration.getScrollFriction()); computeDeceleration 公式 return SensorManager.GRAVITY_EARTH // g (m/s^2) * 39.37f // inch/meter * mPpi // pixels per inch * friction; |
相关文章推荐
- 使用C++实现JNI接口需要注意的事项
- Android IPC进程间通讯机制
- Android Manifest 用法
- [转载]Activity中ConfigChanges属性的用法
- Android之获取手机上的图片和视频缩略图thumbnails
- Android之使用Http协议实现文件上传功能
- Android学习笔记(二九):嵌入浏览器
- android string.xml文件中的整型和string型代替
- i-jetty环境搭配与编译
- android之定时器AlarmManager
- android wifi 无线调试
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- android 代码实现控件之间的间距
- android FragmentPagerAdapter的“标准”配置
- Android"解决"onTouch和onClick的冲突问题
- android:installLocation简析
- android searchView的关闭事件
- SourceProvider.getJniDirectories