我正在打开对话框片段。但是,它不会占据整个屏幕。我的意思是它留下了一些空间。
下面是我的代码:
public class MyDialogFragment extends DialogFragment implements View.OnClickListener{
private Context context = getActivity();
private ImageView imageViewCancel;
private TextView textViewTitle;
private View view;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
view = inflater.inflate(R.layout.layoutfile, container, false);
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
textViewTitle = (TextView) view.findViewById(R.id.textView_Screen_Title);
setHeader("Some title");
imageViewCancel = (ImageView) view.findViewById(R.id.imageView_Cancel);
imageViewCancel.setOnClickListener(this);
//to hide keyboard when showing dialog fragment
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
return view;
}
private void setHeader(String screenTitle) {
textViewTitle.setText(screenTitle);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.imageView_Cancel :
dismiss();
break;
}
}
@Override
public void onStart() {
super.onStart();
getDialog().getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
}
}
参考快照
我想以全屏模式打开它,这样就不会看到背景透明。也尝试过WindowManager.LayoutParams.MATCH_PARENT
,ViewGroup.LayoutParams.MATCH_PARENT
但没有任何效果。