I'm having trouble aligning the fragments to the center of the view pages, in a way that the user can see multiple fragments on the screen. This problem has already been solved before, but not when the fragments have different size.
Can ViewPager have multiple views in per page? is one link that I used. The pagercontainer solution on it works but is very slow. My solution was to set ViewPager padding through setPadding(int, int, int, int)
method and false
for setClipToPadding
. Doing so makes the fragments look as if they're aligned in the center, but assumes that all fragments are the same size (since setPadding
is a global setting for a View
). So having different fragment sizes just completely messes the alignment.
I was hoping if someone knew how to make it so that the current fragment in view pager can be aligned to center without the use of padding. That way one could have different fragment sizes. Alternatively, could someone suggest how to achieve center alignment with padding with variable fragment sizes?
PS: I've searched everywhere online and couldn't find a solution.