答案 0 :(得分:0)
使用此库
可以实现与此类似的效果https://github.com/Azoft/CarouselLayoutManager
尝试根据您的屏幕尺寸提供可见项目
layoutManager.setMaxVisibleItems(1);
- 并且您可以根据需要更改以下侦听器,默认情况下,它们提供一个侦听器,如com.azoft.carousellayoutmanager.CenterScrollListener。
layoutManager.setPostLayoutListener(new CarouselLayoutManager.PostLayoutListener() {
@Override
public ItemTransformation transformChild(@NonNull View child, float itemPositionToCenterDiff, int orientation) {
final float scale = (float) (1.5f * (1.5f * -StrictMath.atan(Math.abs(itemPositionToCenterDiff) + 1.0) / Math.PI + 1));
final float translateY;
final float translateX;
if (CarouselLayoutManager.VERTICAL == orientation) {
final float translateYGeneral = child.getMeasuredHeight() * (1 - scale) / 1f;
translateY = Math.signum(itemPositionToCenterDiff) * translateYGeneral;
translateX = 0;
} else {
final float translateXGeneral = child.getMeasuredWidth() * (0.8f - scale) / 1.5f;
translateX = Math.signum(itemPositionToCenterDiff) * translateXGeneral;
translateY = 0;
}
return new ItemTransformation(scale, scale, translateX, translateY);
}
});
希望这会对你有所帮助......