I need to implement viewpager that has look & feel and animation as that of stackview widget in android. I have already looked into https://github.com/blipinsk/FlippableStackView/tree/master/library/src/main/java/com/bartoszlipinski/flippablestackview. But this doesn't fit my purpose, as the views are animated via flip animations.Any help will be appriciated.
Asked
Active
Viewed 663 times
1 Answers
0
Never mind, I solved the problem by implementing custom PageTransfrormer.
code:
public class DepthPageTransformer implements ViewPager.PageTransformer {
private static final float DEFAULT_CURRENT_PAGE_SCALE = 0.8f;
private int dimen;
public void transformPage(View view, float position) {
view.setScaleX(DEFAULT_CURRENT_PAGE_SCALE);
view.setScaleY(DEFAULT_CURRENT_PAGE_SCALE);
dimen = view.getWidth();
if(position < -1) {
view.setAlpha(0);
} else if(position <= 0) {
view.setAlpha(1.0f);
view.setTranslationX(0);
view.setTranslationY(0);
} else if(position <= 1+1) {
view.setTranslationX(dimen * -position);
view.setAlpha(-0.5f * position + 1.0f);
view.setTranslationX((-dimen / 1.1F) * position);
view.setTranslationY((dimen / 9.9f)*position);
} else {
view.setAlpha(0);
}
}
}
usage: instantiate viewpager and then set custom viewpager transformer as:- viewpager.setPageTransformer(true,new DepthPageTransformer());