While writing a custom layout I just discovered th...
# compose
d
While writing a custom layout I just discovered that having some
alignment
value I can do
Copy code
// alignment = Alignment.Center
val x = alignment.align(myWidth, parentWidth, LayoutDirection.Rtl)
It's a (seemingly) small thing but very nice to not having repeat those boring
width/2 - myWidth/2
etc!
👍 2
s
the
.align
function seems to receive
(IntSize, IntSize, LayoutDirection)
so I guess either I’m missing some import of you didn’t actually pass
myWidth
and
parentWidth
in the first two parameters?
d
this depends on alignment, if it has one axis, such as Horizontal or Vertical, then there will be "Int"s there...