在设置亮度的时候,为什么没有立即生效
答案:1 悬赏:0
解决时间 2021-02-02 11:53
- 提问者网友:萌萌小主
- 2021-02-02 05:35
在设置亮度的时候,为什么没有立即生效
最佳答案
- 二级知识专家网友:孤伤未赏
- 2021-02-02 07:00
你的代码不够完整。应该设置如下:
public void setBrightness(float fl) {
WindowManager.LayoutParams lp = this.getWindow().getAttributes();
int brightness = Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS,0);
// lp.screenBrightness = brightness/255.0f;
lp.screenBrightness = fl;
this.getWindow().setAttributes(lp);
Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, brightness);
}
public void setBrightness(float fl) {
WindowManager.LayoutParams lp = this.getWindow().getAttributes();
int brightness = Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS,0);
// lp.screenBrightness = brightness/255.0f;
lp.screenBrightness = fl;
this.getWindow().setAttributes(lp);
Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, brightness);
}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯