So I know there are ways to do “top left right bottom” but I’m not aware of any way or method to center views…
What I’m trying to do: I have a view which takes up a dynamic dimension. I add child components to it AddView(…) of unknown sizes(to me). I want them to be viewed in the middle¢er of the screen. This isn’t working though!
Is there a way to achieve this?
Where the red lines are equal and the green lines are equal
Here’s a little demo of centering a view within another view – in this case, a GridView within a window.
The key here is set the view want to be centered’s layout to “float” and its gravity to .5,.5. This causes the view to ‘float’ in the center of it’s frame. Ditto you can uses different gravity values to float at top left, bottom right, bottom center etc.
(Note: I found a little bug in GridView while doing this that causes overlap between child gadgets in a gridview – fixed in develop branch).