Monodroid - 如何以编程方式调整设备屏幕亮度?

时间:2013-01-18 01:17:15

标签: android xamarin.android

有人知道如何在Mono for Android中以编程方式调整屏幕亮度。

1 个答案:

答案 0 :(得分:1)

这是一个非常古老的帖子,但由于没有回答,我遇到了同样的问题,我做的是下一个:

WindowManagerLayoutParams windowManagerLayoutParams = new WindowManagerLayoutParams();
windowManagerLayoutParams.CopyFrom(Window.Attributes);
windowManagerLayoutParams.ScreenBrightness = 1f; //set screen to full brightness
Window.Attributes = windowManagerLayoutParams;

将其设置回自动:

WindowManagerLayoutParams windowManagerLayoutParams = new WindowManagerLayoutParams();
windowManagerLayoutParams.CopyFrom(Window.Attributes);
windowManagerLayoutParams.ScreenBrightness = -1;
Window.Attributes = windowManagerLayoutParams;

如果您想保存旧亮度并将其恢复原状,可以将其存储在变量中并再次使用。