【问题标题】:Cannot set navigation bar background color to white on Android无法在 Android 上将导航栏背景颜色设置为白色
【发布时间】:2020-10-02 19:31:48
【问题描述】:

我无法将导航栏设置为白色背景。其他所有颜色都可以,但是当我将其设置为白色时,它在我的手机上显示为深灰色。

我正在使用 Cordova 并使用 SDK 29 编译 apk。我自己创建了一个插件,它使用 setNavigationBarColor 并明确将 Color.WHITE 作为参数传递,但导航栏颜色为深灰色。

正如我所提到的,其他颜色也可以正常工作,我什至可以将导航栏设置为透明。有什么我想念的吗?我需要设置任何特定的标志吗? 我确定这不是我的手机特有的问题,因为例如 Google Rewards 应用程序就可以做到这一点

这是我使用的一段代码: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);

【问题讨论】:

    标签: android cordova


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-12
      • 1970-01-01
      • 2015-05-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多