I am working on an android application where I am using DialogFragment to display the dialog but its width is very small. How I can make this width to fil
option 1. add following code in oncreate in activity
getDialog().getWindow()
.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
or you can Create a custom style for Dialog
then use that style in dialog fragment
@Override public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NORMAL, R.style.CustomDialog);
}
@Override public void onStart() {
super.onStart();
getDialog().getWindow()
.setLayout(WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT);
}
SampleDialogFragment sampleDialogFragment = new SampleDialogFragment();
SampleDialogFragment.show(getActivity().getSupportFragmentManager(), "sometag");
OR you try the following code in style will help you
- @null
Solution 2: dialog.window.setLayout
class TestDialog : DialogFragment() {
override fun onStart() {
super.onStart()
dialog?.window?.setLayout(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT)
}
}