Touch Scroll on View Flipper in Android?

后端 未结 2 1096
别那么骄傲
别那么骄傲 2021-02-06 15:50

I have to achieve that the Touch Scroll on the ViewFlipper. For Example. I have two Images. At First, ViewFlipper shows an First Image. Now I Flung the view from right to left.

2条回答
  •  一向
    一向 (楼主)
    2021-02-06 16:22

    If you need to detect scroll on only viewflipper which is not occupying entire screen, then try the below

    gestureDetector = new GestureDetector(new MyGestureDetector());
    
    viewFlipper.setOnTouchListener(new View.OnTouchListener() {
    
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (gestureDetector.onTouchEvent(event)) {
                    return false;
                }
                return true;
            }
      });
    

    and MyGestureDetector will be same as in http://www.codeshogun.com/blog/2009/04/16/how-to-implement-swipe-action-in-android/

提交回复
热议问题