在 android 全屏模式下创建一个没有操作栏的 Dialogfragment
Make a Dialogfragment in android full screen without actionbar
我正在尝试显示嵌入在另一个片段中的对话框片段,但每当它显示时,顶部有一个纯白色背景占据操作栏通常所在的 space。
如何全屏显示对话框?
这是我的对话片段。
public class HelpDialog extends DialogFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.dialog, container, false);
return view;
}
@Override
public void onStart() {
super.onStart();
Dialog dialog = getDialog();
if (dialog != null) {
dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
dialog.getWindow().setBackgroundDrawable(null);
setStyle(STYLE_NO_FRAME, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
}
}
}
我已经简单地展示了这样的对话框。
HelpDialog = new HelpDialog();
HelpDialog.show(fragmentManager, null);
用这个替换 setstyle
dialog.getWindow().requestWindowFeature(Window.FEATURE_NO_TITLE);
并放在前面
dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);
我正在尝试显示嵌入在另一个片段中的对话框片段,但每当它显示时,顶部有一个纯白色背景占据操作栏通常所在的 space。
如何全屏显示对话框?
这是我的对话片段。
public class HelpDialog extends DialogFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.dialog, container, false);
return view;
}
@Override
public void onStart() {
super.onStart();
Dialog dialog = getDialog();
if (dialog != null) {
dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
dialog.getWindow().setBackgroundDrawable(null);
setStyle(STYLE_NO_FRAME, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
}
}
}
我已经简单地展示了这样的对话框。
HelpDialog = new HelpDialog();
HelpDialog.show(fragmentManager, null);
用这个替换 setstyle
dialog.getWindow().requestWindowFeature(Window.FEATURE_NO_TITLE);
并放在前面
dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);