0

That means I want the view int the custom viewgroup can work like viewpager,but the different is the it can slide from the last to the first(while swipe right)or form the first to last(swipe left). I had try below way.

  1. set the class implements PageAdapter 's getCount() method as follow:

    return Integer.MAX_VALUE; something like https://stackoverflow.com/a/17424525/1872596 but then I get some bugs,where the device lock and unlocked minutes later, ANR occurs.

  2. Custom the viewpager source code ,but failed.It is too hard for a freashman to read about 4000 lines source code.

I hope any one can help me,Thanks a lot.

Community
  • 1
  • 1
RxRead
  • 2,892
  • 2
  • 14
  • 22

1 Answers1

0

Extends from ViewGroup and override dispatchDraw(), and draw the first/last page if is over scrolling It is something like:

protected void computeCirculate(Canvas canvas) {
    if (isAllowCirculate()) {
        canvas.save();
        canvas.translate(-getWidth() * getPageCount(), 0);
        drawPage(canvas, getPageCount() - 1);
        canvas.restore();

        canvas.save();
        canvas.translate(getWidth() * getPageCount(), 0);
        drawPage(canvas, 0);
        canvas.restore();
    }
}

Updated:

Please see my github project: Android_PagedView

Isaiah
  • 424
  • 2
  • 5