Swipe half page in a ViewPager (from compatibility pack)

后端 未结 2 469
遥遥无期
遥遥无期 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:38

    Yes, use the child width as half the page. Therefore, the swiping, which calls next child, will swipe half the page. Good Luck!

    Edit: Checked your sketch again, try implementing 1st, 2nd, 3rd... as different childs. (I predict most of the solution while assuming it will react as GalleryView)

    0 讨论(0)
  • 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);
    }
    
    0 讨论(0)
提交回复
热议问题