简体   繁体   中英

Cannot set navigation bar background color to white on Android

I'm unable to set the navigation bar to a white background. Every other color works, but when I set it to white, it's displayed as a dark grey on my phone.

I'm using Cordova and compiling the apk with SDK 29. I have created a plugin myself that uses setNavigationBarColor and explicitly passes Color.WHITE as a param but I get a dark grey navigation bar color.

As I mentioned, other colors work perfectly fine and I can even set the navigation bar to transparent. Is there anything I'm missing? Are there any flags in specific I need to set? I'm sure it's not something particular with my phone, as the Google Rewards app, for instance, is able to do this

Here's the piece of code I'm using based on: https://developer.android.com/reference/android/view/Window#setNavigationBarColor(int)

final Window window = cordova.getActivity().getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
window.setNavigationBarColor(Color.WHITE);

最后我只是迁移到 Capacitor 并使用了这个插件: https : //github.com/nikosdouvlis/capacitor-navigationbar/tree/master/src

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM