I am using a ViewPager with a PageAdapter (from the compatibility pack v4) to swipe among a horizontal list of boxes. The problem is that my second box from the first page is the first box in the second page (visually and conceptually). Something like this:
The way I am doing now it works. However, this becomes kinda weird because at the middle of the swipe there is a situation that the same box appears twice (like it is shown in the image).
There is a way to swipe only "half" page?
EDIT:
The boxes are an abstraction. In fact each box is a ListView and I create different pages just changing the adapter of each ListView.
- Create one fragment per page
- Override getPageWidth() in PageAdapter to display more than one page
Code:
@Override
public float getPageWidth(int position) {
float nbPages = 2; // You could display partial pages using a float value
return (1 / nbPages);
}
Yes, use the child width as half the page. Therefore, the swiping, which calls next child, will swipe half the page. Good Luck!
Edit: Checked your sketch again, try implementing 1st, 2nd, 3rd... as different childs. (I predict most of the solution while assuming it will react as GalleryView)
来源:https://stackoverflow.com/questions/10569208/swipe-half-page-in-a-viewpager-from-compatibility-pack