美文网首页
修改App内的亮度

修改App内的亮度

作者: yslf | 来源:发表于2016-10-18 14:30 被阅读0次

    1.获取屏幕当前亮度

    int screenBrightness = android.provider.Settings.System.getInt(getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS, 255);

    2.设置屏幕亮度

    public void changeAppBrightness(Context context, int brightness) { Window window = ((Activity) context).getWindow(); WindowManager.LayoutParams lp = window.getAttributes(); if (brightness == -1) { lp.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE; } else { lp.screenBrightness = (brightness <= 0 ? 1 : brightness) / 255f; } window.setAttributes(lp); }

    相关文章

      网友评论

          本文标题:修改App内的亮度

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