0

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 enter image description here

Denis Sologub
  • 7,277
  • 11
  • 56
  • 123
  • 1
    Maybe this repo will help you - otherwise it is hard to tell exactly what you're asking. https://github.com/ToxicBakery/ViewPagerTransforms – OneCricketeer Jan 12 '16 at 10:09
  • 1
    also you should try this solution with own customization http://stackoverflow.com/questions/10098040/android-viewpager-show-preview-of-page-on-left-and-right – ant Jan 12 '16 at 10:31
  • Unfortunately, I cannot use this library because it use more higher API version. I fixed transformation. But ViewCard drop shadow doesn't draw on previous and next pages, only on backgorund... How I can fix it? – Denis Sologub Jan 12 '16 at 10:40
  • let me know if you are still looking for the solution we can work on it. check out my answer below if that can help you – 44kksharma Feb 23 '18 at 11:59

1 Answers1

1

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);

44kksharma
  • 2,740
  • 27
  • 32