我有一项提升屏幕亮度的活动
/* turn screen brightness up */
this.getWindow().getAttributes().screenBrightness = 1;
我发现这个内置的android功能会使某些手机崩溃。
是否有更普遍的方法来提升屏幕亮度?
答案 0 :(得分:2)
设置属性的正确方法是setAttributes()
:
WindowManager.LayoutParams lp = this.getWindow().getAttributes();
lp.screenBrightness = 1;
this.getWindow().setAttributes(lp);
答案 1 :(得分:0)
您可以尝试几乎为1
的值。例如:0.999
。
答案 2 :(得分:0)
如果您希望触摸事件通过,则需要做的不仅仅是设置亮度。
您需要设置视图和布局参数
view.setFocusable(false);
view.setClickable(false);
view.setKeepScreenOn(false);
view.setLongClickable(false);
view.setFocusableInTouchMode(false);
layoutParams.height = LayoutParams.FILL_PARENT;
layoutParams.width = LayoutParams.FILL_PARENT;
layoutParams.flags = 280; // You can try LayoutParams.FLAG_FULLSCREEN too
layoutParams.format = PixelFormat.TRANSLUCENT; // You can try different formats
layoutParams.windowAnimations = android.R.style.Animation_Toast; // You can use only animations that the system to can access
layoutParams.type = LayoutParams.TYPE_SYSTEM_OVERLAY;
layoutParams.gravity = Gravity.BOTTOM;
layoutParams.x = 0;
layoutParams.y = 0;
layoutParams.verticalWeight = 1.0F;
layoutParams.horizontalWeight = 1.0F;
layoutParams.verticalMargin = 0.0F;
layoutParams.horizontalMargin = 0.0F;
查看我的original post。