I'm trying to add the edge-to-edge stuff for the gesture navigation bar to the Tip Time app from Google. I added the transparent navigationBarColor XML tag to themes.xml as well as the following code to the onCreate() function of MainActivity.kt:
This was directly copy-pasted from the documentation. Android Studio says that "it cannot find a parameter with this name" for each of the three margins. I noticed that changing the parenthesis right after <ViewGroup.MarginLayoutParams> to curly braces fixes the compiler error. Maybe the documentation is just wrong?
Anyways, even after fixing that, the app still doesn't look right:
As you can see, the entire view gets shifted up slightly and the "Cost of Service" TextView is partially cut-off by the app bar. What would I need to change to implement the system/navigation bar insets for edge-to-edge content so the UI looks nice? Also, as a side-question, how can I change the dark blue color of the system status bar to match the color of the app bar so that they look blended?


As per documentation for edge to edge contents:
So, while handing the window insets (especially the top one), you can't use the default
ActionBar, instead you need to customize that withAppBarLayoutandToolBar, and to make it act as theActionBar, usesetSupportActionBar(), and aNoActionBarapp theme; it'd be<style name="Theme.TipTime" parent="Theme.MaterialComponents.DayNight.NoActionBar">in the shared repo.The reason that the sample uses the default
ActionBarinstead of a customized one; when it comes to handle the top window insets, it won't affect the defaultActionBar; notice that you pass in the activity's root layout tosetOnApplyWindowInsetsListenercallback, and as theActionBaris not a part of the activity, it won't be affected. Therefore the activity is shifted up behind theActionBarwhen the top inset is removed. So, to solve this you have either to totally remove the defaultActionBaror to use a custom toolbar instead.Use a transparent status bar color in the app's theme: