Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-108884

Android app layout too small if FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS is set on the Window

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.4.1
    • Extras: Android
    • None
    • Reproduced on Android API 23 and 28 and 29 (I tried several phones and emulators), but not on API 30, 31 or 33. The bug didn't exist on Qt 5.15.2
    • Android
    • Next, 2023wk02FOQtforAndroid, 2022wk50FOQtforAndroid, 2022wk52FOQtforAndroid

    Description

      In my android app I want to set the color of the android navigation bar. For this, I derived my own subclass of QtActivity and added this code in the onCreate method:

      Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setNavigationBarColor(0xff0000ff);

      For the color to be visible, it is necessary to set the FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS flag. The color is properly set, but this also has a side effect in the Qt app to add some empty space between the navigation bar and the app surface (the white stripe above the buttons in the screenshot below).

      The same effect is obtained if I use a custom android theme (android:theme="@style/AppTheme" set in the <application> tag of my AndroidManifest.xml), which use the following theme defining the equivalent flags in XML:

      <style name="AppTheme" parent="android:Theme.Material">
          <item name="android:navigationBarColor">@color/blue</item>
          <item name="android:windowDrawsSystemBarBackgrounds">true</item>
      </style>
      

       Note that for the custom theme to be applied, I had to use a workaround to prevent QtActivity to override the theme with Theme_Holo_Light (see QTBUG-44579).

       

      I attach 2 zip files containing minimal projects reproducing the issue using both methods described above.

       

      Note: the problem might come from QtLayout.java, in the onSizeChanged method, where the app height is computed in a way which returns the same erroneous height as I observe on my device.

       

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qtandroidteam Qt Android Team
              xalioth Fabien Chéreau
              Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes