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

Alex

05/28/2021, 11:04 AM
Is there a way to prevent the parent composables padding to clip the shadow of the child-composables?
e.g. to prevent this:
f

Filip Wiesner

05/28/2021, 11:08 AM
I think that all top-level scroll componets clip children. In this example I would remove the padding of parent and set it on children
a

Alex

05/28/2021, 11:09 AM
So every child needs to set the padding separately? This seems to be really un-DRY though?
Oh wow, I just found out that it's all about the ordering of the modifier
This clips:
Copy code
Modifier
.padding(horizontal = 24.dp)
.verticalScroll(rememberScrollState())
This does not clip:
Copy code
Modifier
.verticalScroll(rememberScrollState())
.padding(horizontal = 24.dp)
Interesting (TM)
f

Filip Wiesner

05/28/2021, 11:12 AM
Oh! You are not using "top-level scroll componet" then 😄 Yeah, this makes sense...
a

Alex

05/28/2021, 11:13 AM
I am using a
Column
and enable the scroll and padding on that component via the modifier.. is this the wrong way to go about things? 😄
f

Filip Wiesner

05/28/2021, 11:14 AM
If there will more than those few children like on the pic than yes. You should use
LazyColumn
a

Alex

05/28/2021, 11:16 AM
Yeah this is what I gathered from the available info. From my understanding it's the same as
RecyclerView
vs
ScrollView
right?
ScrollView
has its uses too, so if the lists are short and not too dynamic I would use a
Column
with
scrollModifier
. Is this the right way to do it though?
f

Filip Wiesner

05/28/2021, 11:20 AM
Exactly. But I personally would just use
LazyColumn
for everything scrollable since it's not that much harder. But for small lists you can certainly use
Column
with scroll modifier if that's what you prefer.
4 Views