I am trying to do some animation in the page swipe in view pager by overriding the transformPage() method, such that when I swipe from right to left the new page (page coming from the right side) should appear below the previous page as soon as the animation starts and then the previous page should slide to the left side over the new page. When I swipe from left to right the new page should directly slide over the previous page and covers it completely. But I am not able to achieve it. I have tried the following:-
if(position > 0 && position < 1)
{
int pageWidth = page.getWidth();
float translateValue = (-position * pageWidth);
if(translateValue < pageWidth)
{
translationX = translateValue;
}
else
{
translationX = 0;
}
}
else
{
alpha = 1;
scale = 1;
translationX = 0;
}
Please provide some suggestions. Thanks