https://kotlinlang.org logo
#doodle
Title
# doodle
m

M.C. Escher

03/29/2024, 10:11 AM
in a GridPanel i have set
rowSpacing
to a value > 0 ... is it possible to position a row's contents vertically centered? maybe that's not the proper approach, my goal is basically that the view in each row should be center-aligned vertically within the row
n

Nick

03/29/2024, 2:27 PM
yep, just use the
cellAlignment
property. it defaults to fill now, which means every item takes up the full area of its cells. but you could set it to something else like the following:
Copy code
{
    it.centerY eq parent.centerY
}
just keep in mind that
GridPanel
doesn’t clip its items to their cells; it just ensures that
parent
in the
cellAlignment
refers to the correct cell(s) an item belongs to. this isn’t an issue if you keep the default `rowSizingPolicy`/`columnSizingPolicy`, since they ensure each row/col are large enough to fit the biggest item. but other policies might mean items could bleed out of their cells based on your definition of
cellAlignment
.
m

M.C. Escher

03/29/2024, 2:49 PM
thanks for your answer. i'll check it out