I have a VerticalViewPager
whose Fragment
content I want to scroll horizontally. The vertical paging works fine until the horizontal content is big enough to scroll. After that the touch events are not passed on to the ViewPager
and so paging no longer works.
MVCE
This can be reproduced by setting up a simple project as given in this answer that I just posted.
Replace the fragment_one.xml
file with
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true" >
<TextView
android:id="@+id/textview"
android:textSize="30sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</HorizontalScrollView>
</RelativeLayout>
and set the text to anything long enough to scroll horizontally.
Things I've tried
NestedScrollView
: That quickly turned out to be a dead end since it is apparently not available for horizontal scrolling. I thought about converting the source code to aHorizontalNextedScrollView
but that would not be a trivial project.- Custom
HorizontalScrollView
: I tried converting answers like this and this for horizontal scrolling, but was unsuccessful. I'm going to continue experimenting in this area. - This is not a DoubleViewPager but I feel like the solution should be similar.