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

Archie

08/30/2020, 3:25 PM
How can I make
TopAppBar
consume
Window Inset
? Doing:
Copy code
TopAppBar(
    modifier = Modifier.fillMaxWidth()
        .statusBarsPadding()
        .wrapContentHeight(),
...
just result in something like this where the added padding is just white and not the TopAppbar Color.
n

Niklas Schnettler

08/30/2020, 6:00 PM
I encountered the same problem. I wrote a slightly modified version of AppBar which propagates the modifier to the AppBar Content (a Row) instead of the surface. That fixed the problem for me. I don't know if there is a better solution though. You can find it here: https://github.com/Sh4dowSoul/Compose-Scrobbler/commit/31eb88edde860c4d6e74f0cf3440b701673197c8
a

Archie

08/31/2020, 7:26 AM
Thats exactly what i though of doing as well.. but i was thinking whether this behavior was intended... or is it a “bug”
n

Niklas Schnettler

08/31/2020, 8:34 AM
Yeah, I'm wondering about that as well
a

Archie

08/31/2020, 9:10 AM
Hi @Adam Powell, is it possible to know if this was an expected behavior or is it something that will be changed in the future?
a

Adam Powell

08/31/2020, 1:48 PM
It's nonstandard to apply a modifier parameter to an inner element, but that's a standard, not a compiler-enforced rule. 🙂 Our library components are unlikely to be changed to work that way
But the standard components may be changed in the future to account for the insets in general.
n

Niklas Schnettler

08/31/2020, 2:00 PM
Great, thanks for the info. It would be really nice to have the standard components handling the insets out of the box.
a

Archie

08/31/2020, 2:17 PM
Alright thank you very much!
5 Views