当RecyclerView的父布局是ConstraintLayout时,如果要实现横向滚动,需要将RecyclerView的requestDisallowInterceptTouchEvent设置为true。

这是因为父布局ConstraintLayout默认会拦截触摸事件,如果不设置requestDisallowInterceptTouchEvent为true,当手指滑动RecyclerView时,父布局会优先处理滑动事件,导致RecyclerView无法正常滚动。

设置requestDisallowInterceptTouchEvent为true后,RecyclerView就能够优先处理滑动事件,从而实现横向滚动。

android RecyclerView 父布局是ConstraintLayout 横向滚动为什么需要requestDisallowInterceptTouchEvent配置为true才行

原文地址: http://www.cveoy.top/t/topic/is80 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录