开发者

Is there a way to control how dark the screen gets when it dims?

Is there a way to programmatically set how dark the screen gets when it dims ? I would like to get it as dark as possible without turning it off and locking it.

It could be a setting in the device as long as I can set it via code like how I can set the screen timeout for example:

Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, 60000);
开发者_运维技巧

Thanks,


This is how you can dim it on timeout:

Settings.System.putInt(context.getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS, someIntValue);

and

WindowManager.LayoutParams lp = getWindow().getAttributes();
lp.screenBrightness = (float) (someIntValue/ 255.0);
getWindow().setAttributes(lp);

you need to override onUserInteraction() to reset back to regular value for screen brightness.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜