-1
我在我的羅盤應用程序中使用了一個ImageView,它在傳感器值發生變化時旋轉。問題是當設備達到173至186度角度時,我的ImageView開始從0-360度角連續旋轉。在這個應用程序運行完美之前,我添加了一段代碼以降低ImageView的旋轉速度後開始了這個特殊問題。ImageView不斷旋轉
的方法加入到降低轉速
protected float[] lowPass(float[] input, float[] output) {
if (output == null) return input;
for (int i=0; i<input.length; i++) {
output[i] = output[i] + ALPHA * (input[i] - output[i]);
}
return output;
}
傳感器事件監聽器從那裏方法被調用
private SensorEventListener mySensorEventListener = new SensorEventListener() {
.
.
.
public void onSensorChanged(SensorEvent event) {
.
.
.
SensorManager.getOrientation(rotationMatrix, orientationValues);
accelVals = lowPass(orientationValues, accelVals);
azimuth = (int) Math.toDegrees(accelVals[0]);
azimuth = (azimuth +360)%360;
allowRotating=true;
dialer.post(new RotateRunnable(azimuth));
.
.
.
}
};
會很高興如果任何人能幫助我
請嘗試將其降至更具體的問題。 – poolie 2012-08-08 06:11:15
編輯問題請檢查。 – 2012-08-08 06:50:01