0

Whenever I tried put the default/custom scrollView outside the viewPager the viewPager does not loading at all. I try to set the android:fillViewport="true" parameter but that does not help at all. Also I use that class https://stackoverflow.com/a/31440577/4776020 and it works, but not 100% correctly. The view on each page in ViewPager is adjusting into the longest one.

         <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="9"
            android:orientation="vertical"
           >

            <ProgressBar
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:id="@+id/loadScreenContent" />
<CustomScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
            <CustomViewPager
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/screenViewPager" />
                </CustomScrollView>
</LinearLayout>

CustomScrollView

public class CustomScrollView extends ScrollView{

    private GestureDetector mGestureDetector;

    public CustomScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mGestureDetector = new GestureDetector(context, new YScrollDetector());
        setFadingEdgeLength(0);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        return super.onInterceptTouchEvent(ev) && mGestureDetector.onTouchEvent(ev);
    }

    // Return false if we're scrolling in the x direction
    class YScrollDetector extends GestureDetector.SimpleOnGestureListener {
        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            return Math.abs(distanceY) > Math.abs(distanceX);
        }
    }
}
Community
  • 1
  • 1
Expiredmind
  • 788
  • 1
  • 8
  • 29
  • did you got solution for this?..i am also having the same issue – Bhavesh Feb 24 '18 at 09:51
  • I change my approach. I suppose for the more complicated pages in view pager is better to use FragmentPagerAdapter, and define the the single view as Fragment. You can find many examples how to do it on the web. – Expiredmind Feb 26 '18 at 09:00

0 Answers0