解决VerticalViewPager中嵌套ScrollView滑动问题

来源:互联网 发布:卡拉卓华软件 编辑:程序博客网 时间:2024/05/23 11:54
package com.slfinance.app.slb.common.ui.view;import android.content.Context;import android.util.AttributeSet;import android.view.MotionEvent;import android.view.View;import android.widget.ScrollView;/** * Created by xionglh on 2016/03/19. */public class MyInnerScrollView extends ScrollView {    public MyInnerScrollView(Context context, AttributeSet attrs) {        super(context, attrs);    }    private int mLastY = 0;    @Override    public boolean onTouchEvent(MotionEvent ev) {        int y = (int) ev.getY();        View childView = getChildAt(0);        switch (ev.getAction()) {            case MotionEvent.ACTION_DOWN:                mLastY = y;                break;            case MotionEvent.ACTION_MOVE:                if (mLastY-y> 0&&childView != null && childView.getMeasuredHeight() <= getScrollY() + getHeight()) {                    return false;                }                break;        }        return super.onTouchEvent(ev);    }}

0 0
原创粉丝点击