为什么我的搜索栏亮度设置锁定更改,我该如何解决
why my seek bar brightness setting locked for change and how can i fix it
我使用了一些代码来改变项目页面中自定义搜索栏的亮度。但是每当我使用此代码时,我都无法通过通知栏更改 phone 的亮度。它被锁定了。
我怎样才能同时访问它们?
val backLightValue = (it.view.progress / 100f)
settingLawTextData.seekBarProgress = backLightValue
val layoutParams = activity?.window?.attributes
layoutParams?.screenBrightness = backLightValue
activity?.window?.attributes = layoutParams
我还使用此代码将亮度级别恢复为原始级别,
但是通知面板中的亮度控制搜索栏仍然被锁定
override fun onClick(v: View?) {
when (v?.id) {
R.id.imgCancel -> {
val brightness = android.provider.Settings.System.getInt(activity?.contentResolver, android.provider.Settings.System.SCREEN_BRIGHTNESS)
val layoutParams: WindowManager.LayoutParams = requireActivity().window.attributes
layoutParams.screenBrightness = brightness / 100.0f
activity?.window?.attributes = layoutParams
findNavController().navigateUp()
}
}
}
每当你想让系统再次获得电源时使用这个来设置亮度:
val layoutParams = requireActivity().window?.attributes
layoutParams?.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
requireActivity().window?.attributes = layoutParams
我使用了一些代码来改变项目页面中自定义搜索栏的亮度。但是每当我使用此代码时,我都无法通过通知栏更改 phone 的亮度。它被锁定了。 我怎样才能同时访问它们?
val backLightValue = (it.view.progress / 100f)
settingLawTextData.seekBarProgress = backLightValue
val layoutParams = activity?.window?.attributes
layoutParams?.screenBrightness = backLightValue
activity?.window?.attributes = layoutParams
我还使用此代码将亮度级别恢复为原始级别, 但是通知面板中的亮度控制搜索栏仍然被锁定
override fun onClick(v: View?) {
when (v?.id) {
R.id.imgCancel -> {
val brightness = android.provider.Settings.System.getInt(activity?.contentResolver, android.provider.Settings.System.SCREEN_BRIGHTNESS)
val layoutParams: WindowManager.LayoutParams = requireActivity().window.attributes
layoutParams.screenBrightness = brightness / 100.0f
activity?.window?.attributes = layoutParams
findNavController().navigateUp()
}
}
}
每当你想让系统再次获得电源时使用这个来设置亮度:
val layoutParams = requireActivity().window?.attributes
layoutParams?.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
requireActivity().window?.attributes = layoutParams