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

mattinger

06/02/2022, 8:53 PM
Other than manually putting in dividers between each element, is there a good way to put a divider between elements of a column? I’m not convinced a vertical arrangment can insert some sort of composable, or force any drawing. It seems to only be able to position items that are already children.
j

Joseph Hawkes-Cates

06/02/2022, 9:30 PM
I don’t see anything that stands out as being able to do that in the Column or Row composables directly, but there may be some way to do it with a modifier although I’m not seeing anything out of box that stands out as being able to do this.
FWIW, when I’ve needed dividers in my app so far its either in between a handful of elements and the one line after each element to add the divider is not too bad or it’s in a LazyColumn and I’m iterating over items to add them so it’s only one line to add the divider for each item.
c

Colton Idle

06/02/2022, 11:31 PM
I don't believe theres a concept of item decorators in compose (yet?) so I think the best you can do is have it be in the item composable itself and potentially just have an arg for whether or not you want to show it (i.e. if you dont want to show a divider for the last item in a list)
👍 2
z

Zach Klippenstein (he/him) [MOD]

06/03/2022, 3:01 PM
You can make a custom column layout that records all the bounds of its children and then passes them to a draw modifier to draw the dividers.
7 Views