Fullscreen DialogFragment overlaps with StatusBar
The problem is in the transaction.add(containerId, fragment) part.
You have it set to:
transaction.add(android.R.id.content, fragment)
, and it is the setting of it to android.R.id.content that is causing the overlap.
Instead, set it to the id of the parent's content frame in the calling activity.
For example, in my code the main activity parent layout was a DrawerLayout, with id of drawer_layout, so my fix was
MyDialogFragment fragment = new MyDialogFragment ();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
transaction.add(R.id.drawer_layout, frag)
.addToBackStack(null).commit();
If you want DialogFragment in fullscreen and also want statusbar with your own color, you may add this in onCreate() method on your DialogFragment.
setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_DeviceDefault_Light_NoActionBar_Fullscreen);
You may also add below code in onCreateView method for status bar color.
getDialog().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getDialog().getWindow().setStatusBarColor(getResources().getColor(R.color.colorPrimaryDark));