根据光线改变显示亮度

时间:2019-05-02 11:01:07

标签: c# android visual-studio xamarin

有必要根据从光传感器接收到的数据来更改显示亮度,请帮忙。

public void OnSensorChanged(SensorEvent s)
{
     if (s.Sensor.Type == SensorType.Light)
     {
          System.Diagnostics.Debug.WriteLine("Brightness" + s.Values[0]);
     }        
}

1 个答案:

答案 0 :(得分:0)

您可以使用WindowManager更改亮度

Window.Attributes.ScreenBrightness = 0.0

    //     value of less than 0, the default, means to use the preferred screen brightness.
    //     0 to 1 adjusts the brightness from dark to full bright.
    //     [Android Documentation]