I'm not really getting the point of this default s...
# compose
f
I'm not really getting the point of this default surface in a new Compose Activity. What's it's purpose? And why does it set the background color?
s
Well I guess this is just an example
You don't have to include it if your root composable is a
Scaffold
or some other composable that includes
Surface
f
Oh interesting, I didn't know Scaffold includes Surface
s
Yep many other material components include Surface
f
thank you
yea I've tried to read that but it didn't say much to me
I also didn't notice a difference removing it, probably because all my screens use Scaffold
s
Yeah if you remove it in the Greetings example and run the app in dark mode, you can see your
Text
won't pick up the white color automatically so it will show black text on a black background
f
ah this makes sense, thank you very much!
👍 1
c
@Florian I also asked something similar to this a while back. And one thing I learned (from Nick Butcher I think) is that a surface also clips it's children which compose doesn't clip children by default, so you could run into some issues in that.
f
@Colton Idle what do you mean by "clip"?
c
In xml land the equivallent is
android:clipChildren
which is set to true by default. In compose, clipping is set to false by default.
f
interesting, thank you