在scrollView中想要嵌套一个可滑动的textView,不要用scrollView嵌套scrollView,给textView添加以下设置即可

 1 textView.movementMethod = ScrollingMovementMethod.getInstance()
 2 textView.setOnTouchListener(object : View.OnTouchListener {
 3                     override fun onTouch(v: View?, event: MotionEvent?): Boolean {
 4                         if(event?.action ==MotionEvent.ACTION_DOWN){
 5                             //通知父控件不要干扰,即屏蔽父控件的该事件以及该事件之后的一切action
 6                             v?.parent?.requestDisallowInterceptTouchEvent(true)
 7                         }
 8                         if(event?.action ==MotionEvent.ACTION_MOVE){
 9                             //通知父控件不要干扰,即屏蔽父控件的该事件以及该事件之后的一切action
10                             v?.parent?.requestDisallowInterceptTouchEvent(true)
11                         }
12                         if(event?.action ==MotionEvent.ACTION_UP){
13                             v?.parent?.requestDisallowInterceptTouchEvent(false)
14                         }
15                         return false
16                     }
17                 })

设置后textView即可不被父scrollView拦截的滑动

 

相关文章:

  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
  • 2021-09-08
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
  • 2021-06-25
猜你喜欢
  • 2021-11-18
  • 2021-06-13
  • 2021-12-16
  • 2021-04-26
  • 2022-12-23
  • 2022-12-23
  • 2022-01-08
相关资源
相似解决方案