Reputation: 7819
I try to write PageTransformer
for ViewPager
viewPager.setPageTransformer(false, new ViewPager.PageTransformer() {
@Override
public void transformPage(View page, float position) {
float factor = (float)Math.pow(0.5, Math.abs(position));
page.setScaleX(factor);
page.setScaleY(factor);
}
});
But it works only if I don't set padding and page margins. How to fix this code if padding and page margins not 0?
I need view like below and animation on scroll
Upvotes: 0
Views: 747
Reputation: 2830
you can get an Idea from my sample project, I also used PageTransformer
I had customized the ViewPage to achieve it without using negative margin, find a sample project here https://github.com/44kksharma/Android-ViewPager-Carousel-UI
it should work in most cases but you can still define page margin with
mPager.setPageMargin(margin in pixel);
Upvotes: 1