https://kotlinlang.org logo
#compose-android
Title
# compose-android
j

Jon Bailey

03/28/2024, 10:18 AM
Hi, I've run into the issue where WindowInsets don't work on a second ComposeView, I see from here the suggestion is to do
composeView.consumeWindowInsets = false
. This roughly makes sense to me, but I just wondered if there is any downside to doing this/why false isn't the default?
c

Colton Idle

03/28/2024, 2:04 PM
Not sure if this is helpful, but I know there were a bunch of things in the view system that compose seemingly went the opposite with that helps with edge to edge stuff. 1. Is that views would clip by default, vs in compose they dont 2. In recycler view there was like 2 things you had to set on it, in order to work nicely with edge to edge. I think one of them was called like clipToPadding. now you dont need that in compose. all of that to say that I would just do whatever works. lol I've implemented edge to edge in like 10 apps total. 5 of them in xml and the other 5 in compose (im an android contractor so i work on a lot of diff apps). and with xml there were so many random attrs we had to set correctly vs compose.
t

Timo Drick

03/28/2024, 2:14 PM
It is on by default because when you mixing legacy views and compose and also using the Modifier.windowInsets.... to add padding to your compose views the legacy views and the compose Modifier will try to synchronize the consumed insets. When you turn it off i think than it will just ignore the consumed insets from the legacy view. (Maybe?)
So just to be clear. I guess that when you do consume some insets in your legacy views normally this insets would be excluded from the compose WindowInsets so you do not add padding for the already consumed insets. If you turn this off. Than you need to make sure that you do not have too much padding for your insets.