我实现了下面的对话框片段。我希望状态栏的颜色是透明的,状态栏的文本颜色是在明亮的主题黑暗。此外,文本颜色需要在黑暗的主题白色。
我该如何实现它?
不过,我知道当清除dim标志时,它可以解决上述问题。但我需要dim!!!dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
public class MyDialogFragment extends DialogFragment {
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
LogUtil.i(TAG, "onCreateDialog() call");
AlertDialog alertDialog = new AlertDialog.Builder(getContext(), R.style.MyDialogStyle1)
.setView(binding.getRoot())
.create();
alertDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
Window window = alertDialog.getWindow();
WindowManager.LayoutParams attributes = window.getAttributes();
attributes.height = CustomViewUtil.getScreenH(getContext());
attributes.width = (int) (CustomViewUtil.getScreenW(getContext()) * 0.8);
attributes.gravity = Gravity.END;
window.setAttributes(attributes);
window.setWindowAnimations(R.style.NavigationDrawerDialogAnimation);
alertDialog.setCanceledOnTouchOutside(true);
...
return alertDialog;
}
@Override
public void onStart() {
super.onStart();
LogUtil.i(TAG, "onStart() call");
Dialog dialog = getDialog();
if (dialog != null) {
Window window = dialog.getWindow();
int width = window.getAttributes().width;
int height = ViewGroup.LayoutParams.MATCH_PARENT;
window.setLayout(width, height);
}
}
}
1条答案
按热度按时间guicsvcw1#
添加此样式。
然后将此样式添加到应用AndroidManifest.xml中的Activity。