Horizo​​ntalScrollView内滚动型 - 禁用垂直滚动时水平滚动正在进行中正在进行、水平、Horizo、ntalScrollView

由网友(没有胸就不要凶)分享简介:我有一个父是滚动型,它拥有Horizo​​ntalScrollView作为它的一个子视图。所有作品完美,但是当有人触发垂直滚动,水平滚动停止,或引起的颤动。在它的上面,还有在冰淇淋三明治一些bug不处理的垂直运动对Horizo​​ntalScrollView好,如果它是在一个滚动型,其含量比屏幕较小(在这种情况下,没有...

我有一个父是滚动型,它拥有Horizo​​ntalScrollView作为它的一个子视图。所有作品完美,但是当有人触发垂直滚动,水平滚动停止,或引起的颤动。在它的上面,还有在冰淇淋三明治一些bug不处理的垂直运动对Horizo​​ntalScrollView好,如果它是在一个滚动型,其含量比屏幕较小(在这种情况下,没有垂直滚动)。糖豆机器人处理它正常,但IceCreamSandwich由于某些原因检测到垂直运动,并停止水平滚动。

I have a parent which is ScrollView, which holds a HorizontalScrollView as one of it's child views. All works perfectly, but when someone is triggering vertical scroll, the horizontal scroll stops, or is jittering. On top of it, there is some bug in Ice Cream Sandwich which does not handle vertical movement on HorizontalScrollView well, if it is inside a ScrollView, which content is smaller than the screen (in that situation, there is no vertical scrolling). Jelly Bean android handles it properly, but IceCreamSandwich for some reason detects the vertical movement, and stops the horizontal scrolling.

我怎么会去让父滚动视图禁用它的垂直滚动,当水平滚动被触发?因此,当有人被水平滚动的Horizo​​ntalScrollView,并在做的过程中,手指奇迹了一下Y轴,我不想让父母滚动型来捕获垂直运动。

How would I go about making the parent scrollView disable it's vertical scroll, when a horizontal scroll is being triggered? So when someone is scrolling horizontally the HorizontalScrollView, and while doing it, the finger wonders a bit on a Y Axis, I do not want the parent ScrollView to capture that vertical motion.

任何帮助吗?

推荐答案

只是试试这个

HorizontalScrollView hv = (HorizontalScrollView)findViewById(R.id.myHsView);  // your HorizontalScrollView inside scrollview
    hv.setOnTouchListener(new ListView.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                int action = event.getAction();
                switch (action) {
                case MotionEvent.ACTION_DOWN:
                    // Disallow ScrollView to intercept touch events.
                    v.getParent().requestDisallowInterceptTouchEvent(true);
                    break;

                case MotionEvent.ACTION_UP:
                    // Allow ScrollView to intercept touch events.
                    v.getParent().requestDisallowInterceptTouchEvent(false);
                    break;
                }

                // Handle HorizontalScrollView touch events.
                v.onTouchEvent(event);
                return true;
            }
        });
阅读全文

相关推荐

最新文章