android 因为listview本身的滑动速度太快,我的界面的速度刷新太快,所以视觉上会看不清数据,需要控制listview的滑动速度,找到如下一篇文章:
//摩擦力,用来计算减速度
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 ListView
using 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 ListView
scroll 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(); //用于设置最小加速率和最大速率
//滚动距离 //fling距离
computeDeceleration 公式 return SensorManager.GRAVITY_EARTH // g (m/s^2) |