问题描述:
当 PagerAdapter.getPageWidth() < 1f 时,该项显示在左侧。
我的问题: 我希望该项位于中心或右侧。因此,在向左或向右滚动时,所有项目都将居中对齐。(ViewPager 宽度 = 页面宽度 + 2*页面边距)
我的问题: 我希望该项位于中心或右侧。因此,在向左或向右滚动时,所有项目都将居中对齐。(ViewPager 宽度 = 页面宽度 + 2*页面边距)
你可以在drawChild方法中翻译Canvas,例如:
@Override
protected boolean drawChild(Canvas canvas, View child, long drawingTime) {
canvas.save();
canvas.translate(distance, 0); // change any distance value you want
boolean r = super.drawChild(canvas, child, drawingTime);
canvas.restore();
return r;
}