Android ViewPager with previous and next pages visible? Android ViewPager with previous and next pages visible? android android

Android ViewPager with previous and next pages visible?


I used a negative page margin to partly show the next and the previous pages. The fading edge property can be used to make previous/next page fade:

ViewPager examplePager = (ViewPager) findViewById(R.id.exampleView);examplePager.setPageMargin(-50);examplePager.setHorizontalFadingEdgeEnabled(true);examplePager.setFadingEdgeLength(30);

The lastest support package (revision 4, October 2011) is also required for this to work


enter image description here

Use this code in recyclerview and use snap helper

recyclerView.setAdapter(mAdapter);LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);recyclerView.setLayoutManager(layoutManager);    new LinearSnapHelper().attachToRecyclerView(recyclerView); recyclerView.setScrollingTouchSlop(  recyclerView.TOUCH_SLOP_PAGING);

more info about snaphelper layout