zoukankan      html  css  js  c++  java
  • 解决ScrollView嵌套ViewPager出现的滑动冲突问题

    /**

     
        *
     
          解决ScrollView嵌套ViewPager出现的滑动冲突问题
          */
          public class ScrollView1 extends ScrollView {
          private boolean canScroll;
     
          private GestureDetector mGestureDetector;
          View.OnTouchListener mGestureListener;
     
          public ScrollView1(Context context, AttributeSet attrs) {
     
          super(context, attrs);
          mGestureDetector = new GestureDetector(new YScrollDetector());
          canScroll = true;
     
          }
          @Override
          public boolean onInterceptTouchEvent(MotionEvent ev) {
     
          if(ev.getAction() == MotionEvent.ACTION_UP)
              canScroll = true;
          return super.onInterceptTouchEvent(ev) && mGestureDetector.onTouchEvent(ev);
     
          }
     
          class YScrollDetector extends SimpleOnGestureListener {
     
          @Override
          public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
              if(canScroll)
                  if (Math.abs(distanceY) >= Math.abs(distanceX))
                      canScroll = true;
                  else
                      canScroll = false;
              return canScroll;
          }
     
          }
          }
  • 相关阅读:
    Go
    Go
    Go
    Go
    Go
    Go
    爬虫常用相关库
    Go
    python基础第7天(day19)
    python基础第五天(day17)元组,集合,字符串操作 字符编码:
  • 原文地址:https://www.cnblogs.com/manmanlu/p/4691323.html
Copyright © 2011-2022 走看看