Well ... there is a way to do this. You need to save 2 or 3 elements in memory:
vpPager.setOffscreenPageLimit(3); // or 2
Then configure your viewer as follows:
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="0px"
android:paddingLeft="24dp"
android:paddingRight="12dp"
android:layout_weight="1" />
Then you need to configure these properties of the pager in the containing fragment or activity:
ViewPager vpPager = (ViewPager) view.findViewById(R.id.vpPager);
vpPager.setClipToPadding(false);
vpPager.setPageMargin(12);
Finally, adjust the width inside the adapter:
class MyPageAdapter : FragmentStatePagerAdapter {
@Override
public float getPageWidth (int position) {
return 0.93f;
}
}
You can check the full example in the following two links:
Visible adjacent
ViewPager with outstanding children
source
share