Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dialog FLAG_DIM_BEHIND doesn't work on Android 5.x (Lollipop)

I dim the background of a DialogFragment using this code:

    Window window = getDialog().getWindow();
    WindowManager.LayoutParams windowParams = window.getAttributes();
    windowParams.dimAmount = 0.75f;
    windowParams.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND;
    window.setAttributes(windowParams);

This works fine on Kitkat and below, but stopped working on Lollipop. I suspect it has to do with the fact that my Activity is using the style Theme.AppCompat.Light.DarkActionBar, which uses the Material Theme on 5.x, and something in that theme prevents the DIM flag from working. I tried messing with the various theme flags, but to no avail so far.

like image 345
Eduard Avatar asked Jun 12 '15 19:06

Eduard


1 Answers

Apparently this was caused by Lux Dash app I had installed, that controls the brightness of the screen. Geesh. Took me a while to figure this out! I uninstalled it and the dimming came back. [Not a bug]

like image 117
Eduard Avatar answered Oct 21 '22 08:10

Eduard