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

Tung97 Hl

01/31/2023, 11:58 AM
Hi everyone I have a question. Why do compose show an error when I did not use Scaffold’s padding parameter? Why it is important?
s

Stylianos Gakis

01/31/2023, 12:00 PM
Because your content may then draw behind the Scaffold making it not interactable or completely invisible with no way to scroll to see it.
t

Tung97 Hl

01/31/2023, 4:22 PM
Thank you guys I got it.
c

Colton Idle

01/31/2023, 5:28 PM
Do people typically just apply that padding to their router in this case? Or do you need to use the paddingValue to pass into a Lazy* which has a contentPadding param?
s

Stylianos Gakis

01/31/2023, 5:34 PM
I think the passed paddings are not of transparent items, so it's not like you'll see what's behind it. With that said, if your container is one which takes contentPadding, it may be better to use that as it may interact better with scroll positions as those paddings may animate in and out? I'd test it though to see if it has any difference. The big difference is if the top bar or whatever else is transparent, then if you use the paddings as actual padding you may see no background behind if the container you use has a different color than whatever is behind, but if you use contentPadding it'd have the container occupy the space under the transparent items too, making it look normal again.
c

Colton Idle

01/31/2023, 5:48 PM
hm. yeah. i might need to play around with this a bit more. i mostly just surpress the error 🙈
s

Stylianos Gakis

01/31/2023, 5:59 PM
Uhmm, that is definitely not a good idea 😅
d

dorche

01/31/2023, 6:36 PM
Don’t forget that Scaffold is overkill if your layout is really just a Column. I don’t think I’ve seen an animated version of Scaffold with BottomBar + paddings that works really well when you navigate (with slide animation at the very least) and it needs to hide the bottom bar on that new page… (we ended up rolling a custom implementation that uses a Box instead of a Column…)
6 Views