I need to set the child view as center of the ViewPager and also I would like to show some part of the next and previous views to the current view sides(like current screen
For one app I implemented similar the following way, with standard ViewPager
:
Make pages full-screen with the actual content in an inner layout. For example, make the full-screen layout a RelativeLayout
with transparent background and the actual content another RelativeLayout
centered in the parent. If I remember right, the reason for this was that with just the inner layout as a page, the ViewPager
would not have taken all the screen width on some devices such as Galaxy Nexus.
Use ViewPager.setPageMargin()
to set up a negative page margin i.e. how much of the next/previous page you want to show. Make sure it only overlaps the transparent region of the parent full-screen layout.
Call ViewPager.setOffscreenPageLimit()
to adjust the off-screen page count to at least 2
from the default 1
to ensure smooth paging by really creating the pages off-screen. Otherwise you will see next/previous pages being drawn while already partially showing on screen.