ScrollView Inside ScrollView

后端 未结 13 725
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 15:40

I Know people from Google have asked us not to put Scrollable view inside another Scrollable view but is there any official statement from them directing us not to do so?

13条回答
  •  北海茫月
    2020-11-22 16:10

    childScrollView.setOnTouchListener(new View.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;
            }
    
            return false;
        }
    });
    

    v.getParent() = parent scrollView.

提交回复
热议问题