首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >更改滚动视图页的偏移量以更改页面

更改滚动视图页的偏移量以更改页面
EN

Stack Overflow用户
提问于 2016-04-25 21:15:40
回答 1查看 1K关注 0票数 0

在viewpager中,当我们滚动超过一半屏幕时,当我们释放它时,viewpager转到下一页或上一页,我想要的是改变偏移量。

例如,当用户滚动200dp时,我的浏览页将转到下一页。

有人能帮我解决这个问题吗?

谢谢你的帮助。

EN

回答 1

Stack Overflow用户

发布于 2016-04-25 21:39:28

PageTransformer的工作方式是让你访问一个回调,其中你有两个参数:页面和位置(介于-1 :完全向左,+1 :完全向右)。此回调如下:

代码语言:javascript
复制
@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
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36841688

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档