ViewPager with multiple visible children and selected bigger
To achieve this result, I ended up using PixPlicity's MultiViewPager and coding a simple PageTransformer
as suggested by @Blackbelt:
private float mScale = 0.8f;
private class ScalePageTransformer implements ViewPager.PageTransformer{
@Override
public void transformPage(View view, float position) {
if(position==0){
ViewCompat.setScaleX(view, 1);
ViewCompat.setScaleY(view, 1);
}
else{
ViewCompat.setScaleX(view, mScale);
ViewCompat.setScaleY(view, mScale);
}
}
}
The result is something like:
You have to use a PageTransform for this purpose. The callback you have to implement receives two parameters. The former is the View object, the latter is an int
. When its value is zero, it means the view objects refers to the fully visible object to the center. -1 and -1, are the fully visible views to the left and right respectively. You can use this value to implement the transformation you want. Using ViewCompat, for instance, you can change the translationX, translationY and Scale values
I have the same problem like this. My solution is use MultipleViewPager + PagerTransformer
and it works fine.