xmuSistone / VerticalSlideFragment

vertical slide to switch to the next fragment page, looks like vertical viewpager
1.61k stars 305 forks source link

用了DrawerLayout, 侧滑会很难触发,这个是跟咱们的库有冲突吗 #34

Closed hahagod closed 7 years ago

xmuSistone commented 7 years ago

有冲突

hahagod commented 7 years ago

这个要重写DrawerLayout 吗?

xmuSistone commented 7 years ago

不能重写DrawerLayout。 常规来讲的话,这个只是详情页,我是没考虑过在外围加上DrawerLayout的。 你试下这个:

@Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if (ev.getAction() == MotionEvent.ACTION_DOWN) {
            downX = ev.getRawX();
            downY = ev.getRawY();
            isAtTop = isAtTop();
            scrollMode = MODE_IDLE;
            getParent().requestDisallowInterceptTouchEvent(true);
        } else if (ev.getAction() == MotionEvent.ACTION_MOVE) {
            if (scrollMode == MODE_IDLE) {
                float xDistance = Math.abs(downX - ev.getRawX());
                float yDistance = Math.abs(downY - ev.getRawY());
                if (xDistance > yDistance && xDistance > mTouchSlop) {
                    scrollMode = MODE_HORIZONTAL;
                    getParent().requestDisallowInterceptTouchEvent(false);
                } else if (yDistance > xDistance && yDistance > mTouchSlop) {
                    scrollMode = MODE_VERTICAL;
                    if (downY < ev.getRawY() && isAtTop) {
                        getParent().requestDisallowInterceptTouchEvent(false);
                    }
                }
            }
        }
        return super.onInterceptTouchEvent(ev);
    }

CustWebView和CustScrollView你都替换成这样,再试试看

hahagod commented 7 years ago

选择规格是弹出了一个右边的侧滑,所以我就用了drawerlayout!

ps: 你给的代码,有很多变量是没有的,我直接定义吗?

@xmuSistone