I'm using a library called FancyCoverFlow
which extends Gallery
. I tried adding :
android:gravity="center"
in the layout to center child elements with no luck. The gallery is stretched on the entire screen, I made its background red to make sure.
How do you center Gallery child elements vertically ?
The library is no longer maintained but I'm posting the solution anyway.
The specific line you have to modify is the last one in the method
dispatchDraw(Canvas canvas)
inFancyCoverFlowItemWrapper
class :From :
To :
Just instead of drawing the view at
top = 0
you calculate the middle and use it instead.FancyCoverFlowItemWrapper
instantiation resides inFancyCoverFlowItem
class, so normally you would extend it and override the said method, but it's not public, so you have no access to it.I ended up duplicating instead or extending the classes :
So now in my xml I don't use FancyCoverFlow anymore but MyFancyCoverFlow instead.
Here's a fork of the fixed bug : https://github.com/Mehdiway/FancyCoverFlow