怎么监听scroll view 的滑动距离
展开全部
在onTouchListener中可以监听到用户的点击行为,但是ScrollView在MotionEvent.Action_UP之后还会滑动一段距离,这时候就需要起一个延时的handler,这个handler实时记录当前ScrollView的滑动距离,以此来判断滑动状态
interface onScrollListener{<br> void onScrollStop();<br> void onScroll(int y);<br>}<br>scrollView.setOnTouchListener(new OnTouchListener() {
private int lastY = 0;
private int touchEventId = 1001;<br> private OnScrollListener listener;
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
View scroller = (View) msg.obj;
interface onScrollListener{<br> void onScrollStop();<br> void onScroll(int y);<br>}<br>scrollView.setOnTouchListener(new OnTouchListener() {
private int lastY = 0;
private int touchEventId = 1001;<br> private OnScrollListener listener;
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
View scroller = (View) msg.obj;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询