我有一个带有PageTransformer实现的ViewPager,它为ViewPager的下一页做了一些时髦的东西.我的实现看起来像这样:
class ZoomOutPageTransformer implements ViewPager.PageTransformer {
private static final float MIN_SCALE = 0.85f;
private static final float MIN_ALPHA = 0.5f;
@Override
public void transformPage(View view, float position) {
int pageWidth = view.getWidth();
if (position < -1) { // [-Infinity,-1)
// This page is way off-screen to the left.
view.setAlpha(0);
} else if (position <= 0) { // [-1,0]
// Use the default slide transition when moving to the left page
} else if (position < 1) { // (0,1]
do …Run Code Online (Sandbox Code Playgroud)