https://kotlinlang.org logo
#compose
Title
# compose
g

Geert

12/01/2020, 11:31 AM
I have been looking into SwiftUI lately, and fount this spacing property for rows and columns. I have been searching for it in Jetpack Compose but cannot find it? Is that correct? Do I have to add my own spacing between every item? for example
Copy code
Spacer(modifier = Modifier.width(4.dp))
a

allan.conda

12/01/2020, 11:34 AM
that, or Modifier.padding()
padding = space in compose world. Given it’s a modifier, it adds a space over the component. No such thing as margins.
Spacer() is useful when spacing components though,
Copy code
ComponentA()
Spacer(8.dp)
ComponentB()
instead of
Copy code
ComponentA(Modifier.padding(bottom = 4.dp))
ComponentB(Modifier.padding(top = 4.dp))
there used to be
arrangementSpacing
for
Column
, seems it’s internal now
l

len

12/01/2020, 11:41 AM
FlowRow/Column still has
mainAxisSpacing
, but it might change because it's still experimental and its behavior might not be what you want
s

sindrenm

12/01/2020, 11:47 AM
I think you might be looking for
Arrangement.spacedBy
?
Copy code
Row(arrangement = Arrangement.spacedBy(4.dp))
Also exists for
Column
,
ScrollableRow
and
ScrollableColumn
, but AFAIK not (yet?) for their lazy counterparts.
👍 3
a

allan.conda

12/01/2020, 11:48 AM
oooh
g

Geert

12/01/2020, 11:56 AM
@sindrenm thank you, I will look into that!
🙌 1
a

Andrey Kulikov

12/01/2020, 1:36 PM