开发者

Android : Dimming down screen

I would like to dim-down my screen in my project as im working on. I have an android phone that runs 2.2. It works great if I use the following code:

WindowManager.LayoutParams lp = getWindow().getAttributes();
    lp.screenBrightness = 0;
    getWindow().setAttributes(lp);

But when I tried the code on the emulator and on phone of my friend, that both runs 2.3, it goes to lock screen and i dont know why. Anyone who has an idea how I can 开发者_JAVA百科dim the screen down for 2.3 devices?

Thanks!


Try this instead:

WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = 0.01f;
getWindow().setAttributes(lp);

This is probably not the best way to fix this particular issue, but it works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜