---
title: "Set pages pre-view in ViewPager"  
description: "Set pages pre-view in ViewPager"  
author: "Anonymous User"  
published: 2015-11-13  
updated: 2015-11-13  
canonical: https://www.mindstick.com/forum/33590/set-pages-pre-view-in-viewpager  
category: "android"  
tags: ["android", "android controls"]  
reading_time: 1 minute  

---

# Set pages pre-view in ViewPager

You can help me with this? (Make [preview](https://www.mindstick.com/forum/429/i-want-to-get-full-path-of-lt-asp-fileupload-gt-and-then-client-can-click-the-preview-button-to-see-what-file-he-here-has-uploaded) of next [page](https://www.mindstick.com/articles/13031/why-to-make-a-wikipedia-page) on [screen](https://www.mindstick.com/forum/33644/loading-screen-during-ajax-call)) ![Set pages pre-view in ViewPager](https://www.mindstick.com/mindstickforums/d0af8d46-e87b-4408-a300-6d65b16935a8/images/8b4fc3b2-0bec-4a36-8612-a24485678887.png)\

## Replies

### Reply by Anonymous User

Well... there is a way to do this. You need to keep 2 or 3 items in memory with:

```
vpPager.setOffscreenPageLimit(3); // or 2
```

Then, tune your viewpager like this:

```
<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" />
```

Next, you need to tune 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);// Now setup the adapter as normalFinally, adjust the width inside the adapter:class MyPageAdapter : FragmentStatePagerAdapter {    @Override    public float getPageWidth (int position) {        return 0.93f;    }       // ...}
```


---

Original Source: https://www.mindstick.com/forum/33590/set-pages-pre-view-in-viewpager

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
