I was looking for vertical viewpager then I found this answer
it's working fine, but now I need to slide only half of the fragment.
I did this before, using horizontal viewpager with below solution
Override the getPageWidth method of PagerAdapter and make it return 0.5f;
but because I'm using vertical viewpager instead of horizontal viewpager, and FragmentPagerAdapter does not have any override method to return height
just replace VerticalPageTransformer
class with this source
private class VerticalPageTransformer implements ViewPager.PageTransformer {
@Override
public void transformPage(View view, float position) {
if (position < -1) {
view.setAlpha(0);
} else if (position <= 1) {
view.setAlpha(1);
view.setTranslationX(view.getWidth() * -position);
float yPosition = position * (float)(view.getHeight() / 2.5);
view.setTranslationY(yPosition);
} else {
view.setAlpha(0);
}
}
}
it works perfectly ;)