android Q content above navigation bar
Asked Answered
Q

3

7

we are targeting our application at api 28 and draw content under status bar. For this we are using following flag and styles :

window.addFlags(FLAG_LAYOUT_NO_LIMITS)

<item name="windowNoTitle">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:windowDrawsSystemBarBackgrounds">false</item>

everything is okay on Android Pie (content layout under status bar and above navigation bar). In android Q, navigation bar is translucent and shows over the application content enter image description here

Qua answered 4/9, 2019 at 8:45 Comment(2)
you want to hide navigation bar?Gamecock
Hide or keep old version ( concent strat above the navigation bar)Qua
A
4

In android api 29, Bottom bar is overlapping the content.

Add this code in your activity

    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE);


    ViewCompat.setOnApplyWindowInsetsListener(getWindow().getDecorView(), new OnApplyWindowInsetsListener() {
        @Override
        public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
            v.setPadding(0, 0, 0, v.getPaddingBottom() + insets.getSystemWindowInsetBottom());
            return insets;
        }
    });
Arrivederci answered 13/1, 2020 at 14:54 Comment(1)
This worked for me running on Android 12. Slightly modified kotlin solution to replace deprecated "insets.getSystemWindowInsetBottom()" : ViewCompat.setOnApplyWindowInsetsListener(window.decorView) { v, insets -> val systemBarInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars()) v.setPadding(0, 0, 0, systemBarInsets.bottom) insets }Pomology
E
3

the "problem" underlies the behavior of the FLAG_LAYOUT_NO_LIMITS, mixed with the new gesture functionality in api 29

https://medium.com/androiddevelopers/gesture-navigation-going-edge-to-edge-812f62e4e83e https://medium.com/androiddevelopers/gesture-navigation-handling-visual-overlaps-4aed565c134c

a little solution is:

window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
window.statusBarColor = Color.TRANSPARENT

and don't set

android:fitsSystemWindows
android:windowTranslucentStatus
android:windowIsTranslucent
Electroscope answered 17/9, 2019 at 17:28 Comment(2)
Still same in Android 29Arrivederci
The most important thing, don't set getWindow().setFlags(FLAG_LAYOUT_NO_LIMITS, FLAG_LAYOUT_NO_LIMITS);Icbm
H
0

You should this to you main activity

    view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
    view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);

and then create a new styles.xml file for v29

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <!-- values-v29/themes.xml -->
  <style name="AppTheme"
      parent="Theme.AppCompat.Light">
      <item name="android:navigationBarColor">
          @android:color/black
      </item>

      <!-- Optional, if drawing behind the status bar too -->
      <item name="android:statusBarColor">
          @android:color/black
      </item>
  </style>
</resources>

source: https://medium.com/androiddevelopers/gesture-navigation-going-edge-to-edge-812f62e4e83e

Headwind answered 24/9, 2019 at 11:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.