gpt4 book ai didi

android - 状态栏在全屏对话框 fragment android 中将其颜色更改为黑色

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:22:06 27 4
gpt4 key购买 nike

我正在使用对话框 fragment 。问题是状态栏颜色更改为黑色。如何将其更改为其他颜色? fragment 内部的原因很奇怪, Activity 正常。它在 DialogFragment 里面只有黑色

        @Override
public void onStart() {
super.onStart(); //super.onStart() is where dialog.show() is actually called on the underlying dialog, so we have to do it after this point
Dialog d = getDialog();
if (d != null) {

int width = ViewGroup.LayoutParams.MATCH_PARENT;
int height = ViewGroup.LayoutParams.MATCH_PARENT;
d.getWindow().setLayout(width, height);
d.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

}
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Dialog dialog = new Dialog(getActivity(), R.style.full_screen_dialog);
return dialog;

}

最佳答案

您必须设置 FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS 以指示此窗口负责绘制系统栏的背景。

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
dialog.getWindow().setStatusBarColor(yourColor);
}

关于android - 状态栏在全屏对话框 fragment android 中将其颜色更改为黑色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41468213/

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