The following way will work even if you are working on a relative layout. Follow the following steps:
Go to styles.xml and then under the theme just added, add these two attributes:
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
My theme setting for the dialog is as under:
<style name="DialogTheme" parent="Theme.AppCompat.Dialog" >
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
Make sure that the theme has a parent as Theme.AppCompat.Dialog Another way would be just make a new style in styles.xml and change it as per the code above.
Go to your Dialog Fragment class and in the onCreate() method, set the style of your Dialog as:
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setStyle(DialogFragment.STYLE_NORMAL,R.style.DialogTheme); }