Swipe half page in a ViewPager (from compatibility pack)

后端 未结 2 522
遥遥无期
遥遥无期 2020-12-15 01:01

I am using a ViewPager with a PageAdapter (from the compatibility pack v4) to swipe among a horizontal list of boxes. The problem is that m

2条回答
  •  没有蜡笔的小新
    2020-12-15 01:43

    1. Create one fragment per page
    2. Override getPageWidth() in PageAdapter to display more than one page

    Code:

    @Override
    public float getPageWidth(int position) {
        float nbPages = 2; // You could display partial pages using a float value
        return (1 / nbPages);
    }
    

提交回复
热议问题