I want my view pager animation like below image from left and right side both. I have 3 pages. the middle one should not move. when I will move left or right only left or the right page will scroll with little fade in middle screen.
I am making animation with overriding the transformPage(View view, float position) method of PageTransformer class in view pager
private final PageTransformer mPageTransformer2 = new PageTransformer() {
@Override
public void transformPage(View view, float position) {
Log.d("CalViewPager", "transformPage: " + position );
if (position < 0.0f ) {
// Pin the left page to the left side.
view.setTranslationX(getWidth() * -position);
view.setAlpha(Math.max(1.0f - position, 0.0f));
} else{
// Use the default slide transition when moving to the next page.
view.setTranslationX(0.0f);
view.setAlpha(1.0f);
}
};
Above code works fine from right side and i am trying to do in left side also. So, i try to understand the position value of transform(View view, float position) method. but i am unable to figure out how it changes with view?
What i found if i swap right side each position value increase by 1 and if in left side then it get decrease by 1. but how would I know which view has which position value?
Note: - please comment if you didn't get my question or need more explanation