2

I want dialog to appear completely in corner. I am setting gravity this way:

    Window win = dialog.getWindow();
    WindowManager.LayoutParams wmlp = win.getAttributes();
    wmlp.gravity = Gravity.TOP | Gravity.RIGHT;
    wmlp.horizontalMargin = 0;
    wmlp.verticalMargin = 0;

Margins don't affect anything here. Layout inspector also doesn't work on dialog so I can't really inspect what is setting margin/padding.

enter image description here

Can I show this dialog fragment completely in corner (without recreating custom overlay fragment over whole screen that acts as a dialog)?

JoKr
  • 4,976
  • 8
  • 27
  • 39

1 Answers1

0

That extra padding/margin may have something to do with the background drawable. Change the style of your dialog to set android:windowBackground and android:background to be transparent by doing something like this:

    <style name="TransparentDialog" parent="@style/Theme.AppCompat.Light.Dialog">
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:background">@android:color/transparent</item>
    </style>

(I believe that android:windowBackground is important here, and you may not need to set android:background.)

Thanks goes to andrew who answered this question for helping to provide a solution.

Community
  • 1
  • 1
Cheticamp
  • 61,413
  • 10
  • 78
  • 131