代码语言:javascript复制
viewPager.setPageTransformer(false, new ViewPager.PageTransformer() {
@Override
public void transformPage(@NonNull View view, float position) {
float alpha = 0.0f;
if (0.0f <= position && position <= 1.0f) {
alpha = 1.0f - position;
} else if (-1.0f <= position && position < 0.0f) {
alpha = position 1.0f;
}
view.setAlpha(alpha);
}
});