Can You Make An Alert Dialog Take 100% Of The Width On Screen?

I am trying to make my alert dialog (not custom dialog), take up 100% of the width on screen from end to end ,but even if I set it to match parent width, it still takes up like 90% of the width with some gaps on left and right(also i m trying to set the gravity to bottom and still theres some space from bottom too) . not sure if I do need a custom dialog to do this or is there any way an alert dialog can take up the entire screen width without being custom? Any ideas? Here's my code for reference:

AlertDialog.Builder builder = new AlertDialog.Builder(getMyActivity());
     AlertDialog dialog = builder.create();
            dialog.getWindow().setLayout(MATCH_PARENT, WRAP_CONTENT);
            dialog.getWindow().getAttributes().windowAnimations =; 
            WindowManager.LayoutParams wmlp = dialog.getWindow().getAttributes();

            wmlp.gravity = Gravity.BOTTOM ;


Try Below code

AlertDialog.Builder alertDialog = new AlertDialog.Builder(this,;

or add custom theme in your style.xml

 <style name="DialogTheme" parent="android:Theme.Dialog">

<item name="android:layout_width">match_parent</item>
<!-- No backgrounds, titles or window float -->
<item name="android:windowBackground">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>

while inflating your dialogue set this theme

dialog = new Dialog(this,;