How do I extend my activity's view behind the navigation bar on Android 10 and later?

Viewed 121

If you open Google Calendar on a phone running Android 10 (or later, presumably), you'll see the affordance for the ability to swipe up from the bottom of the screen is still there as a grey bar, but it's rendered over the top of the activity itself.

Google Calendar

On my own app, however, this navigation bar at the bottom (if indeed that's what it is) has a grey background and my activity presumably stops at the top of it.

My app

How do I do what Google Calendar has done?

1 Answers

add this line to your app theme:

<item name="android:statusBarColor">@color/colorPrimary</item>

like:

<style name="MainActivityTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:statusBarColor">@color/colorPrimary</item>
    <item name="android:windowLightStatusBar" tools:ignore="NewApi">false</item>
</style>
Related