Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Color of the navigation bar on Android 10
Qt 6.11 is out! See what's new in the release blog

Color of the navigation bar on Android 10

Scheduled Pinned Locked Moved Solved Mobile and Embedded
6 Posts 3 Posters 3.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Francky033
    wrote on last edited by Francky033
    #1

    Hi !,

    On Android 10, the navigation bar always appears in white (here, I've highlighted it in grey to make it more visible.)!

    Screenshot_20200508-111531.jpg

    How can I change the color of this bar?

    I tried to add these lines to the res/libs.xml file

    <style name="MyTheme" parent="android:Theme.Material">
    <item name="android:navigationBarColor">#FF0000</item>
    <item name="android:windowBackground">#FF0000</item>
    </style>

    and I added the option <activity android:theme="@style/MyTheme" to the activity line in AndroidManifest.xml but it doesn't work...

    With my thanks,

    Franck

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Francky033
      wrote on last edited by
      #2

      I've made some modifications:

      I created a /res/styles.xml file containing :

      <?xml version='1.0' encoding='utf-8'?>
      <resources>
      <style name="MyTheme" parent="android:Theme.Material">
      <item name="android:navigationBarColor">#FFFF0000</item>
      <item name="android:windowBackground">#FFFF0000</item>
      </style>
      </resources>

      and I refer to this style in the AndroidManifest.xml as follows:

      <android application:theme="@style/MyTheme" ...

      At startup, the navigation bar and the background are red, but 1 second later, the navigation bar becomes white again. I'm testing on a Samsung A10 running Android 10 and UI2

      Thanks !

      1 Reply Last reply
      0
      • L Offline
        L Offline
        Louiss97
        wrote on last edited by
        #3

        @Francky033 said in Color of the navigation bar on Android 10:

        I've made some modifications:
        I created a /res/styles.xml file containing :
        <?xml version='1.0' encoding='utf-8'?>
        <resources>
        <style name="MyTheme" parent="android:Theme.Material">
        <item name="android:navigationBarColor">#FFFF0000</item>
        <item name="android:windowBackground">#FFFF0000</item>
        </style>
        </resources>
        and I refer to this style in the AndroidManifest.xml as follows:
        <android application:theme="@style/MyTheme" ...
        At startup, the navigation bar and the background are red, but 1 second later, the navigation bar becomes white again. I'm testing on a Samsung A10 running Android 10 and UI2
        Thanks !

        Has your problem been solved yet?

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Francky033
          wrote on last edited by
          #4

          No. the changes have no effect. The bar always appears white !

          1 Reply Last reply
          0
          • mmjvoxM Offline
            mmjvoxM Offline
            mmjvox
            wrote on last edited by mmjvox
            #5
            #ifdef Q_OS_ANDROID
            
                            QtAndroid::runOnAndroidThread([=]()
                            {
                                QAndroidJniObject window = QtAndroid::androidActivity().callObjectMethod("getWindow", "()Landroid/view/Window;");
                                window.callMethod<void>("addFlags", "(I)V", 0x80000000);
                                window.callMethod<void>("clearFlags", "(I)V", 0x04000000);
                                window.callMethod<void>("setStatusBarColor", "(I)V", 0xfffce03f); // Desired statusbar color
                                QAndroidJniObject decorView = window.callObjectMethod("getDecorView", "()Landroid/view/View;");
                                    decorView.callMethod<void>("setSystemUiVisibility", "(I)V", 0x00002000);
                            });
            
            
            #endif
            

            I don't remember exactly but may be needed:

            #include <QAndroidJniEnvironment>
            #include <QtAndroid>
            #include <QAndroidJniObject>
            
            1 Reply Last reply
            2
            • F Offline
              F Offline
              Francky033
              wrote on last edited by
              #6

              Fantastic mmjvox !!!!

              You saved my day!!!!!

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved