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.


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]


A bunch of the ActionBarActivities have been Depreciated on the newer OS's with android. I just created one and had a similar problem with android 5.0 and i think the newer 5. 1 So i kind of found a solution(If this doesn't work for you just try an earlier version of android), If your in android studio on the left left click on project then right click on app. a menu should pop up then click on Module Settings... In there there should be a build tools scroll down, If the current one is set to the new beta version set it to 21.1.10 and the Compile sdk version to 5.0 and that worked for me.. Try it if not mess with the build tools version a little (THE NEW VERSION IS SOMETHING LIKE 23.0.0 rc1)

链接地址: http://www.djcxy.com/p/85670.html

上一篇: 找到多个组中的一个匹配组

下一篇: BEHIND不适用于Android 5.x(棒棒堂)