如何限制排名Android的价值取向

时间:2012-01-07 08:17:10

标签: android orientation

如何限制排名中的价值取向

这  http://developer.android.com/reference/android/hardware/SensorManager.html#getOrientation%28float%5B%5D,%20float%5B%5D%29

values[0]: azimuth, rotation around the Z axis.
values[1]: pitch, rotation around the X axis. Default (-180to180)
values[2]: roll, rotation around the Y axis.  Default (-90to90)

我想将值[1]从默认值限制为(-90to90)。怎么办?

public void onSensorChanged(SensorEvent event) {
  // TODO Auto-generated method stub
  synchronized (this) {

    switch(event.sensor.getType()){
      case Sensor.TYPE_ORIENTATION: {
      com.app.labylinthii.Global.setXaxis(Float.toString(event.values[0]));
      com.app.labylinthii.Global.setYaxis(Float.toString(event.values[1]));
      com.app.labylinthii.Global.setZaxis(Float.toString(event.values[2]));
      break;
      }
      case Sensor.TYPE_ACCELEROMETER: {
        break;
      }
    }
  }

谢谢。

0 个答案:

没有答案