Solved Color of the navigation bar on Android 10
-
Hi !,
On Android 10, the navigation bar always appears in white (here, I've highlighted it in grey to make it more visible.)!
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
-
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 !
-
@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?
-
No. the changes have no effect. The bar always appears white !
-
#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>
-
Fantastic mmjvox !!!!
You saved my day!!!!!