Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android Q content above navigation bar

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

like image 419
Nininea Avatar asked Sep 04 '19 08:09

Nininea


2 Answers

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;
        }
    });
like image 113
Hamza Khan Avatar answered Sep 19 '22 05:09

Hamza Khan


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
like image 39
samuele794 Avatar answered Sep 22 '22 05:09

samuele794