Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ViewPager - get a partial view of the next page

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

enter image description here

like image 348
znat Avatar asked Mar 28 '12 12:03

znat


2 Answers

You can try adding this to your PageAdapter:

public float getPageWidth(int position) {     if (position == 0 || position == 2) {         return 0.8f;     }     return 1f; } 
like image 173
Juozas Kontvainis Avatar answered Oct 02 '22 20:10

Juozas Kontvainis


Try using a negative value for ViewPager.setPageMargin.

like image 27
AdamK Avatar answered Oct 02 '22 21:10

AdamK