gpt4 book ai didi

android - 找不到方法 android.view.Window.setStatusBarColor

转载 作者:太空宇宙 更新时间:2023-11-03 10:41:16 29 4
gpt4 key购买 nike

在 5.0 以下的设备上,我收到以下错误:

I/dalvikvm: Could not find method android.view.Window.setStatusBarColor, referenced from method onCreateView
W/dalvikvm: VFY: unable to resolve virtual method 14897: Landroid/view/Window;.setStatusBarColor (I)V

代码是:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getActivity().getWindow();
window.setStatusBarColor(Color.RED);
}

最佳答案

试试这个方法!它对我有用。希望对你也有用。

if (android.os.Build.VERSION.SDK_INT >= 23) {
Window window = this.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(this.getResources().getColor(R.color.colorPrimaryDark, this.getTheme()));
window.setNavigationBarColor(this.getResources().getColor(R.color.white, this.getTheme()));
}

关于android - 找不到方法 android.view.Window.setStatusBarColor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33097665/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com