Samus Arin Samus Arin - 1 year ago 86
Android Question

DialogFragment with clear background (not dimmed)

I'm trying to get the background of a

to be completely clear.

With setting the style item
to true (the default),
displays exactly how I want it to, but has a very dimmed background.

By setting
to false, I get the clear background I want, but the DialogFragment blows up to about 95% of the screen,
leaving only a tiny gap around it where you can see through to the view it overlays.

I've tried ton's of tweaks and cannot seem to override this behavior.

Do I need to use a
to achieve the desired effects, or are there some style
items that I can override ?

Answer Source

What works for me is to adjust the WinowManager.LayoutParams in onStart() of the DialogFragment:

@Override public void onStart() {

    Window window = getDialog().getWindow();
    WindowManager.LayoutParams windowParams = window.getAttributes();
    windowParams.dimAmount = 0.90f;
    windowParams.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download