更改亮度片段对话框

时间:2019-06-18 16:10:17

标签: java android fragment dialogfragment

我尝试在打开对话框片段时更改亮度,我将此代码插入oncreate(),但仅更改一秒钟。

    try {
        curBrightnessValue = Settings.System.getInt(
                getActivity().getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);

        WindowManager.LayoutParams layout = getActivity().getWindow().getAttributes();
        layout.screenBrightness = 1F;
        getActivity().getWindow().setAttributes(layout);

    } catch (Settings.SettingNotFoundException e) {
        e.printStackTrace();
    }

在主要片段中有效

0 个答案:

没有答案