ViewPager - 获取下一个页面的局部视图视图、局部、页面、ViewPager

2023-09-04 23:47:08 作者:期待.转身

我想在ViewPager实现这一

I am trying to achieve this in a ViewPager

第一个片段(蓝色)显示,下一个片段开始时的用户了解,他可以刷卡切换视图必须显示为好,所以。 我们的想法是滚动屏幕的20%以编程到左侧。

The first fragment (blue) is displayed and the beginning of the next fragment must be displayed as well, so the user understands he can swipe to switch views. The idea is scroll 20% of the screen programmatically to the left.

有什么想法,欢迎

编辑:这正是我需要到:中央认为需要重叠两侧意见

This is exactly what I need to to: the central view needs to overlap both side views

推荐答案

您可以尝试添加到您PageAdapter:

You can try adding this to your PageAdapter:

public float getPageWidth(int position) {
    if (position == 0 || position == 2) {
        return 0.8f;
    }
    return 1f;
}