google-developer-training / basic-android-kotlin-compose-training-woof

Apache License 2.0
48 stars 75 forks source link

Material Theming: Android Basics with Compose - Status bar collides with app. #91

Open Elaws opened 3 months ago

Elaws commented 3 months ago

URL of codelab

Codelab link

In which task and step of the codelab can this issue be found?

Task 4. "Add color". Step "Add color palette to theme".

Describe the problem

When replacing color.kt and theme.kt by the requested ones, the app collides with status bar. theme.kt given in starter code is completely different from the one given in solution code.

These kind of errors make the learning experience a bit difficult, it would be nice to review them a bit.

Versions Android Studio version: Iguana 2023.2.1 API version of the emulator: API 34

Additional information

image

willprada commented 2 months ago

I didn't find another issue describing the same error. But I found out that there are 2 version of the code one with branches named starter, material and main, and others where they have the _e2e suffix, meaning edge to edge.

Reviewing both versions of the code, I found out that edge to edge version has the following line:

WindowCompat.setDecorFitsSystemWindows(window, false)

which can be found in the setUpEdgeToEdge function. And the description of the setDecorFitsSystemWindows method says:

If set to false, the framework will not fit the content view to the insets and will just pass through the WindowInsetsCompat to the content view.

link to docs

You can either remove that line or set the second argument as true. I will just set it at true.
But as I said, the branch that do not have the edge to edge config, is the one that they linked at the end of the pathway.