Align the child views in center of the ViewPager android

前端 未结 7 1074
Happy的楠姐
Happy的楠姐 2020-12-09 17:11

I need to set the child view as center of the ViewPager and also I would like to show some part of the next and previous views to the current view sides(like current screen

7条回答
  •  被撕碎了的回忆
    2020-12-09 17:49

    You can use padding for viewPager and set clipToPadding false

    Java

    viewPager.setClipToPadding(false);
    viewPager.setPadding(50, 0, 50, 0);
    

    Kotlin

     viewPager.clipToPadding = false
     viewPager.setPadding(50, 0, 50, 0)
    

提交回复
热议问题