@OverrIDepublic voID onSensorChanged(SensorEvent event) { switch (event.sensor.getType()) { case Sensor.TYPE_ORIENTATION: float[] insIDeval = getValPoints(); event.values[1]=(float) (event.values[1]*2.8); event.values[2]=(float) (event.values[2]*2.8); setValPoints(event.values.clone()); if (insIDeval != null) { float check= insIDeval[0] - event.values[0]; if (-1<=check && check <=1) { //Animation stoped this.stopAnimation(); }else{ if (getdefaltDeviceOrIEntation() == ORENTATION_LANDSCAPE) { // Natural OrIEntation is landscape if (getcurrentDeviceOrIEntation() == 1) { //ORIENTATION_PORTRAIT startPoint = CGPoint.CGPointMake(insIDeval[2],insIDeval[1]); if (insIDeval[0] < event.values[0]) { endPoint = CGPoint.CGPointMake(insIDeval[2]+ event.values[2],insIDeval[1]); } else if (insIDeval[0] > event.values[0]) { endPoint = CGPoint.CGPointMake(insIDeval[2]- event.values[2],insIDeval[1]); } } else if (getcurrentDeviceOrIEntation() == 2) { //Log.i(TAG,"ORIENTATION_LANDSCAPE"); startPoint = CGPoint.CGPointMake(insIDeval[1],insIDeval[2]); if (insIDeval[0] < event.values[0]) { endPoint = CGPoint.CGPointMake(insIDeval[1]- event.values[1],insIDeval[2]); } else if (insIDeval[0] > event.values[0]) { endPoint = CGPoint.CGPointMake( insIDeval[1]+event.values[1],insIDeval[2]); } } } else if (getdefaltDeviceOrIEntation() == ORENTATION_PROTRAIT) { // Natural OrIEntation is portrait if (getcurrentDeviceOrIEntation() == 1) { //Log.i(TAG,"ORIENTATION_PORTRAIT"); startPoint = CGPoint.CGPointMake(insIDeval[1],insIDeval[2]); if (insIDeval[0] < event.values[0]) { endPoint = CGPoint.CGPointMake(insIDeval[1]+ event.values[1],insIDeval[2]); } else if (insIDeval[0] > event.values[0]) { endPoint = CGPoint.CGPointMake(insIDeval[1]- event.values[1],insIDeval[2]); } } else if (getcurrentDeviceOrIEntation() == 2) { //Log.i(TAG,"ORIENTATION_LANDSCAPE"); startPoint = CGPoint.CGPointMake(insIDeval[2],insIDeval[1]); if (insIDeval[0] < event.values[0]) { endPoint = CGPoint.CGPointMake(insIDeval[2]- event.values[2],insIDeval[1]); } else if (insIDeval[0] > event.values[0]) { endPoint = CGPoint.CGPointMake(insIDeval[2]+event.values[2],insIDeval[1]); } } } this.drawVIEw(); } } break;}}
所以我的问题是如果设备的方向改变颠倒图像将旋转到错误的方向(完全相反的方向).我如何解决这个问题以及当设备方向发生变化时实际发生了什么?
谢谢.
它返回4个选项之一ROTATION_0,ROTATION_90,ROTATION_180,ROTATION_270
总结以上是内存溢出为你收集整理的如何检测android中的颠倒方向?全部内容,希望文章能够帮你解决如何检测android中的颠倒方向?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)