Disable childViewPager sliding, but parentViewPager cannot slide in childViewPager

UI architecture is TabLayout+parentViewPager+ Fragment

Fragments of CoordinatorLayout + AppBarLayout + childViewPager

Refer to the

Illustrate the Android event distribution mechanism

About ViewPager nesting ViewPager left and right sliding conflict resolution method

Handles sliding event conflicts for ViewPager nested viewPagers

One way to do this is to use textView+fragments instead of viewPager since viewPager can’t slide. Click textView, switch fragments, and slide parentViewPager

Public Boolean canScrollHorizontally(int direction) {return false; }

Also refer to Android’s analysis of sliding issues arising from nested ViewPager