在viewpager中,当我们滚动超过一半屏幕时,当我们释放它时,viewpager转到下一页或上一页,我想要的是改变偏移量。
例如,当用户滚动200dp时,我的浏览页将转到下一页。
有人能帮我解决这个问题吗?
谢谢你的帮助。
发布于 2016-04-25 21:39:28
PageTransformer的工作方式是让你访问一个回调,其中你有两个参数:页面和位置(介于-1 :完全向左,+1 :完全向右)。此回调如下:
@Override
public void transformPage(View page, float position) {
//Page (0, 1, 2 etc..) is the page
//position goes from -1.0f (totally left) to +1.0f (totally right).
//So you get access to each step of the animation for each position
//and for each page.
//You can then do something like :
page.setScaleX(1.0f + 0.05f * position);
page.setScaleY(1.0f + 0.05f * position);
//Which will scale the views up or down depending on where they are on the screen
}https://stackoverflow.com/questions/36841688
复制相似问题