简体   繁体   English

ScrollView不垂直滚动

[英]ScrollView doesn't vertical scroll

I have ScrollView with width and height fill_parent and I implemented SimpleOnGestureListener like 我有带有宽度和高度的ScrollView fill_parent,并且实现了SimpleOnGestureListener

scroller.setOnTouchListener(new OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    gdt.onTouchEvent(event);
                    return true;
                }
            });

private class GestureListener extends SimpleOnGestureListener {
    @Override
    public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
            float velocityY) {
        if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE
                && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) {
            btnNextQuestion.performClick();
            return true; // Right to left
        }
        return false;
    }
}

and at the moment it reacts only on touch from right to left when is step bigger than constant and not reacts on vertical move. 现在,当步长大于恒定值时,它仅在从右向左触摸时作出反应,而对垂直移动则没有反应。 What to change to ScrollView reacts ( has default behaviour on vertical move, scroll content )? 更改为ScrollView会有什么反应(垂直移动,滚动内容具有默认行为)? Can someone help me ? 有人能帮我吗 ?

You always return true from your onTouch() method inside the OnTouchListener() , and this means that you have consumed the event (do the actual scroll...), so Android will not scroll the view for you. 你总是返回trueonTouch()里面方法OnTouchListener()这意味着你已经消耗的事件(做实际的滚动......),因此Android不会滚动你的看法。

To let Android take care of the scroll just return false from the onTouch() method. 为了让Android处理滚动,只需从onTouch()方法返回false onTouch()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM