Through the analysis of Viewpager event processing, it is found that the key point to solve this problem is to determine whether the part that can be slid horizontally, that is, CanScroll (View, boolean, int, int, int) method
In this method, recursively determine whether the sub-view can slide horizontally, and in the last row to determine whether you can slide horizontally. The key point is to call the viewcompat.canscrollhorizontally (View, int) method to determine if you can swipe sideways. See the source of viewcompat.canscrollhorizontally (view, int) further
Different versions have different implementations
The ICS version overrides canscrollhorizontally (view, int), calls viewcompatics.canscrollhorizontally (view, int)
viewcompatics.canscrollhorizontally (view, int) calls the view new canscrollhorizontally (int) method
Hcviewcompatimpl inherits from Gbviewcompatimpl, without rewriting canscrollhorizontally (View, int) method
Gbviewcompatimpl inherits from Eclairmr1viewcompatimpl, without rewriting canscrollhorizontally (View, int) method
Eclairmr1viewcompatimpl inherits from Baseviewcompatimpl, without rewriting canscrollhorizontally (View, int) method
Baseviewcompatimpl canscrollhorizontally (View, int) method returns false directly
The above source analysis can be summed up in API14 above is called the View New canscrollhorizontally (int) method to determine, and in API13 and below the direct return of false, can be understood as unsupported.
So this is no solution, of course not. Since Viewpager can slide normally above API14 then it is necessary to rewrite the canscrollhorizontally (int) method to view Viewpager's canscrollhorizontally (int) Method source finds that this method does not have version compatibility issues, and can be called directly on API13 and the following versions. The solution is to inherit the Viewpager rewrite CanScroll (View, boolean, int, int, int) method and call canscrollhorizontally (int) directly, as follows:
Read more about my open source project Compatviewpager Https://github.com/xiaopansky/CompatViewPager
Android-resolves an issue where viewpager is nested when it cannot slide in API 13 and the following versions