View Pager with previous and next item smaller in size with infinite scroll

前端 未结 3 1483
轮回少年
轮回少年 2020-12-01 07:06

Want to create the view pager same as following UI, applied custom transformer but not working.

ViewPager.java

public class MyViewPager ext         


        
3条回答
  •  心在旅途
    2020-12-01 07:29

    Using ViewPager2 (that has RecyclerView in it).

    vp2 is instance of ViewPager2

    This worked for me:

    RecyclerView rv = (RecyclerView) vp2.getChildAt(0);
    rv.setPadding(80, 0, 80, 0);
    rv.setClipToPadding(false);
    

    I used FragmentStateAdapter for it and overriding getItemId() and containsItem() for add/remove fragments.

    result is here:

提交回复
热议问题