android view pager swipe animation -


i trying animation in page swipe in view pager overriding transformpage() method, such when swipe right left new page (page coming right side) should appear below previous page animation starts , previous page should slide left side on new page. when swipe left right new page should directly slide on previous page , covers completely. not able achieve it. have tried 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 suggestions.

this should work want, have put in pagertransformer class:

private static final float min_scale_depth = 0.75f;   @override public void transformpage(view page, float position) {     final float alpha;     final float scale;     final float translationx;               if (position > 0 && position < 1) {                 alpha = (1 - position);                 scale = min_scale_depth + (1 - min_scale_depth) * (1 - math.abs(position));                 translationx = (page.getwidth() * -position);             } else {                 alpha = 1;                 scale = 1;                 translationx = 0;             }      page.setalpha(alpha);     page.settranslationx(translationx);     page.setscalex(scale);     page.setscaley(scale); 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -