Android ScrollView取消惯性滚动的方法
2017-04-13 10:12
489 查看
ScrollView中惯性滚动的效果,想让这个ScrollView慢一点滑动或者接近drag(拖拽)操作,就提出了添加阻尼的说法。只要重新fling方法即可,将velocity值极至缩小。
实例如下:
public class CustomHorizontalScrollView extends HorizontalScrollView { private Context context; private ScrollViewListenner listenner; private CustomHorizontalScrollView currentView; public CustomHorizontalScrollView(Context context) { super(context); // TODO Auto-generated constructor stub this.context = context; } public CustomHorizontalScrollView(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub this.context = context; } public CustomHorizontalScrollView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); // TODO Auto-generated constructor stub this.context = context; } @Override public boolean onTouchEvent(MotionEvent ev) { // TODO Auto-generated method stub currentView = this; return super.onTouchEvent(ev); } @Override protected void onScrollChanged(int l, int t, int oldl, int oldt) { // TODO Auto-generated method stub if (null != listenner) { this.listenner.onScrollChanged(currentView, l, t, oldl, oldt); } super.onScrollChanged(l, t, oldl, oldt); } public interface ScrollViewListenner { public void onScrollChanged(CustomHorizontalScrollView view, int l, int t, int oldl, int oldt); } public void setScrollViewListenner(ScrollViewListenner listenner) { this.listenner = listenner; } /** * *阻尼:1000为将惯性滚动速度缩小1000倍,近似drag操作。 @Override public void fling(int velocity) { super.fling(velocity / 1000); } */ }
以上这篇Android ScrollView取消惯性滚动的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
您可能感兴趣的文章:
相关文章推荐
- Android ScrollView取消惯性滚动
- Android textview 不使用ScrollView也可滚动的方法
- Android在ScrollView中嵌入ViewPage,ViewPage不能够左右滚动解决方法
- Android Webview与ScrollView的滚动兼容及留白处理的方法
- android 禁止scrollview 因控件变化自动滚动到底的方法
- Android 设置listview在scrollView中不滚动的方法
- android scrollview 实现上下左右滚动方法
- Android:禁止ScrollView在子控件的布局改变时自动滚动的的方法
- Android TextView多行文本滚动实现与ScrollView的滚动条为隐藏的方法
- android_ScrollView 监听滚动到某个位置的方法
- Android下 scrollview的滚动停止事件的监听方法
- android Gallery 实现短距离滚动 取消惯性
- 分享一个两个Android scrollView同时滚动的方法
- Android布局 屏幕滚动方法 ScrollView
- Android 中 ScrollView滚动不到最底端的解决方法
- Android 中 ScrollView滚动不到最底端的解决方法
- Android 中 ScrollView滚动不到最底端的解决方法
- Android垂直滚动控件ScrollView使用方法详解
- Android 中listview 和scrollview 滚动冲突事件的解决方法
- Android取消标题栏&强制设置横(竖)屏方法