The PageTransformer library which support ViewPager
and ViewPager2
.
dependencies {
implementation 'io.github.vejei.pagetransformer:pagetransformer:x.y.z'
}
If you don't need any configuration use SimplePageTransformer
directly, passing in the required transformer name.
// ViewPager
ViewPager viewPager = view.findViewById(R.id.view_pager);
viewPager.setPageTransformer(false, new SimplePageTransformer(SimplePageTransformer.CUBE_INSIDE));
// ViewPager2
ViewPager2 viewPager = view.findViewById(R.id.view_pager2);
viewPager.setPageTransformer(new SimplePageTransformer(SimplePageTransformer.CUBE_INSIDE));
Or if you need any configuration, like the cube camera distance, construct the corresponding transformer object:
// ViewPager
ViewPager viewPager = view.findViewById(R.id.view_pager);
viewPager.setPageTransformer(false, new CubeInsideTransformer(20));
// ViewPager2
ViewPager2 viewPager = view.findViewById(R.id.view_pager2);
viewPager.setPageTransformer(new new CubeInsideTransformer(20));
For detailed examples, see the samples app.
The all PageTransformerName
of the SimplePageTransformer
including:
CUBE_INSIDE
CUBE_OUTSIDE
DEPTH
FADE_SLIDE
FADE
FAN
GATE
ROTATE_DOWN
ROTATE_UP
ROTATE_HORIZONTAL
ROTATE_VERTICAL
SCALE
SIDE_BY_SIDE
STACK_BOTTOM
STACK_TOP
ZOOM_IN
ZOOM_OUT
All currently available transformers including:
CubeInsideTransformer
CubeOutsideTransformer
DepthTransformer
FadeSlideTransformer
FadeTransformer
FanTransformer
GateTransformer
RotateDownTransformer
RotateUpTransformer
RotateHorizontalTransformer
RotateVerticalTransformer
ScaleTransformer
SideBySideTransformer
StackBottomTransformer
StackTopTransformer
ZoomInTransformer
ZoomOutTransformer