美文网首页
【Android】亮度改变问题-部分手机最大亮度超过255

【Android】亮度改变问题-部分手机最大亮度超过255

作者: 下雨天的小白鞋 | 来源:发表于2022-03-08 11:17 被阅读0次

    小米手机获取了一个亮度900多,就会出现亮度计算错误

                                deltaY = -deltaY;
                                int deltaV = (int) (255 * deltaY * 3 / mScreenHeight);
                                WindowManager.LayoutParams params = JZUtils.getWindow(getContext()).getAttributes();
                                if (((mGestureDownBrightness + deltaV) / 255) >= 1) {//这和声音有区别,必须自己过滤一下负值
                                    params.screenBrightness = 1;
                                } else if (((mGestureDownBrightness + deltaV) / 255) <= 0) {
                                    params.screenBrightness = 0.01f;
                                } else {
                                    params.screenBrightness = (mGestureDownBrightness + deltaV) / 255;
                                }
                                Log.e("Vera_亮度", "mGestureDownBrightness=" + mGestureDownBrightness);
                                int total = 255;
                                if (mGestureDownBrightness > 255) {
                                    mGestureDownBrightness = mGestureDownBrightness * 255 / 2047;
                                }
                                JZUtils.getWindow(getContext()).setAttributes(params);
                                //dialog中显示百分比
                                int brightnessPercent = (int) (mGestureDownBrightness * 100 / 255 + deltaY * 3 * 100 / mScreenHeight);
                                showBrightnessDialog(brightnessPercent);
                                Log.e("Vera_亮度", "brightnessPercent=" + brightnessPercent);
    
    

    相关文章

      网友评论

          本文标题:【Android】亮度改变问题-部分手机最大亮度超过255

          本文链接:https://www.haomeiwen.com/subject/pmovqrtx.html