I have a full screen DialogFragment. everything went well until I tested my app with the new android Nougat (7) version. suddenly I noticed that weird margins appears at the top and bottom of screen.
The parent layout is ConstraintLayout, but even though I tried to change it to LinearLayout or RelativLayout, nothing happend.
I have this code lines :
getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
getDialog().getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getDialog().getWindow().setLayout(getScreenWidth(), getScreenHeight());
any idea?
My solution for this issue was to add the 'DialogFragment' as 'Fragment' instead of dialog.
I removed:
dialog.show(fm, MyDialog.class.getSimpleName());
and added this code instead:
FragmentTransaction transaction = iFm.beginTransaction();
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
ViewGroup root = (ViewGroup) iActivity.findViewById(android.R.id.content).getRootView();
FrameLayout child = new FrameLayout(iActivity);
child.setLayoutParams(new ViewGroup.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
child.setId(R.id.dialog_container);
root.addView(child);
transaction.add(child.getId(), iDialog).addToBackStack(iDialog.getClass().getSimpleName()).commit();
I added the DialogFragment above all content like dialog, but with simple fragment transaction. that was the only workaround that I could figure and it works fine till now like charm :)