In JetpackCompose, we can use LazyColumnFor
as RecyclerView
.
In RecyclerView
, to have a proper margin/padding between items, we need to use ItemDecoration
, as per this article
Like below
class MarginItemDecoration(private val spaceHeight: Int) : RecyclerView.ItemDecoration() {
override fun getItemOffsets(outRect: Rect, view: View,
parent: RecyclerView, state: RecyclerView.State) {
with(outRect) {
if (parent.getChildAdapterPosition(view) == 0) {
top = spaceHeight
}
left = spaceHeight
right = spaceHeight
bottom = spaceHeight
}
}
}
For JetpackCompose LazyColumnFor
, what's the equivalent of ItemDecoration
?