Hi all. With `LazyVerticalStaggeredGrids` , is there a way to dynamically add padding in order to in...
x
Hi all. With
LazyVerticalStaggeredGrids
, is there a way to dynamically add padding in order to indent only certain items in appropriate positions? Code in ๐Ÿงต
Just realised its not super obvious with the screenshot above, but there's two levels of indentation i want to achieve
MyListView.kt
j
You can do a custom arrangement ๐Ÿ™‚ If check in source code for Arrangement.spacedBy, they do like this to put space:
Copy code
internal fun placeSpaceAround(
        totalSize: Int,
        size: IntArray,
        outPosition: IntArray,
        reverseInput: Boolean
    ) {
        val consumedSize = size.fold(0) { a, b -> a + b }
        val gapSize = if (size.isNotEmpty()) {
            (totalSize - consumedSize).toFloat() / size.size
        } else {
            0f
        }
        var current = gapSize / 2
        size.forEachIndexed(reverseInput) { index, it ->
            outPosition[index] = current.roundToInt()
            current += it.toFloat() + gapSize
        }
    }
๐Ÿ‘€ 1
You can implement Horisontal and Vertical Arrangements in one class btw, by implement both interfaces ๐Ÿ™‚