Is it possible to make selected fragment big but other fragments small
ijustyce opened this issue · 2 comments
ijustyce commented
Is it possible to make selected fragment big but other fragments small smoothly just like this
there is the link of this app http://fir.im/tle2
rubensousa commented
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.
rubensousa commented
I've included this in the sample already, so I'm going to close this. It looks cool :)