rubensousa/ViewPagerCards

Is it possible to make selected fragment big but other fragments small

ijustyce opened this issue · 2 comments

Is it possible to make selected fragment big but other fragments small smoothly just like this
screenshot_2016-08-23-17-33-06
there is the link of this app http://fir.im/tle2

Yes, you can scale the cards inside the onPageScrolled of the ShadowTransformer.
The following code would scale the cards from 100% to 110%

 if (currentCard != null) {
            currentCard.setScaleX((float) (1 + 0.1 * (1 - realOffset)));
            currentCard.setScaleY((float) (1 + 0.1 * (1 - realOffset)));
            currentCard.setCardElevation((baseElevation + baseElevation
                    * (CardAdapter.MAX_ELEVATION_FACTOR - 1) * (1 - realOffset)));
 }
...
 if (nextCard != null) {
            nextCard.setScaleX((float) (1 + 0.1 * (realOffset)));
            nextCard.setScaleY((float) (1 + 0.1 * (realOffset)));
            nextCard.setCardElevation((baseElevation + baseElevation
                    * (CardAdapter.MAX_ELEVATION_FACTOR - 1) * (realOffset)));
 }

You just need to make sure the ViewPager's height will be still be greater than the scaled item, otherwise the shadow will be clipped at the top.

I've included this in the sample already, so I'm going to close this. It looks cool :)