android Q content above navigation bar

…衆ロ難τιáo~ 提交于 2019-12-11 06:27:43

问题


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 under Q ( content lay out under status bar and above navigation bar). In android Q , navigation bar is translucent and show over the application content


回答1:


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



回答2:


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



来源:https://stackoverflow.com/questions/57784715/android-q-content-above-navigation-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!