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

William Barbosa

07/27/2020, 12:59 PM
Compose question: I wanna have an edge-to-edge app and I want to add the navigation bar height as bottom padding to a scroll list so that the last item doesn't get cut. Right now, I'm checking if
item == lastItem
inside the loop and updating the bottom padding accordingly. Is there a way of doing what we did in xml files by adding
android:clipToPadding="false"
so that the padding was always added at the end of the scroll or is checking item by item the Compose Way™️? 🤔
t

Timo Drick

07/27/2020, 1:05 PM
There is a clipToPadding modifier. Some Compose functions using them. When you do not use them than it works the same like before i think.
w

William Barbosa

07/27/2020, 1:19 PM
I can't seem to find a
clipToPadding
modifier. I saw a
clipToBounds()
(with is a wrapper to
drawLayer(clip = true)
), so I tried
drawLayer(clip = false)
but that did not work 🤔
t

Timo Drick

07/27/2020, 2:14 PM
Yes sorry. "clipToBounds()"
In genereal i did not had to do anything that it works. Just make sure no component in the hiearchy call clipToBounds.
@William Barbosa did you solve your problem. Just found code from me which work as you discribed:
Copy code
Box(Modifier.padding(bottom = (space + FabSize + space))) {
    VerticalLayoutList(listPosition = scrollerPosition, items = fanartList
    ) { item ->
        Column(Modifier.swipeToRemove(onRemoved = { onFanartAction(item, InventoryItemAction.DELETE) })) {
            Box(modifier = Modifier.fillMaxSize()
                    .padding(start = space, end = space, top = space)
                    .clickable(onClick = { onFanartAction(item, InventoryItemAction.ACTIVATE) })) {
                InventoryFanartListItemView(item)
            }
        }
    }
}
Unfortunately the new LazyColumnItems composable do call clipToBounds 😞 I am using a custom implementation because i also need to keep the scroll position. And my custom implementation do not clip: https://gitlab.com/timod/compose-playground/-/blob/master/compose_list/src/main/java/de/drick/compose/list/LayoutList.kt