问题
I am trying to achieve this in a ViewPager
The first fragment (blue) is displayed and the beginning of the next fragment must be displayed as well, so the user understands he can swipe to switch views. The idea is scroll 20% of the screen programmatically to the left.
Any thoughts are welcome
EDIT: This is exactly what I need to to: the central view needs to overlap both side views

回答1:
You can try adding this to your PageAdapter:
public float getPageWidth(int position) {
if (position == 0 || position == 2) {
return 0.8f;
}
return 1f;
}
回答2:
Try using a negative value for ViewPager.setPageMargin.
回答3:
This function worked better than the answer marked as correct (for me anyway).
@Override
public float getPageWidth(int position) {
return 0.9f;
}
Just place it in your custom PagerAdapter
class.
回答4:
viewpager.setClipToPadding(false);
viewpager.setPageMargin(-50);
来源:https://stackoverflow.com/questions/9907748/viewpager-get-a-partial-view-of-the-next-page