Skip to content

Instantly share code, notes, and snippets.

@vxhviet
Created November 1, 2019 06:30
Show Gist options
  • Save vxhviet/ab8c784d5fcb7f7d4122d156f16b03c5 to your computer and use it in GitHub Desktop.
Save vxhviet/ab8c784d5fcb7f7d4122d156f16b03c5 to your computer and use it in GitHub Desktop.

Question: How to create a ViewPager that can see a part of next and previous item (like a Carousel)

SOURCE, more complex method SOURCE, SOURCE, SOURCE

Answer:

To show preview of left and right pages set the following two values

viewpager.setClipToPadding(false);
viewpager.setPadding(left,0,right,0);

If you need space between two pages in the viewpager then add:

viewpager.setPageMargin(int);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment