[英]Android - get the sensor landscape orientation
I'm working at a game, and the orientation is sensorLandscape. 我在玩游戏,方向是sensorLandscape。
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/GdxTheme" >
<activity
android:name="com.fainosag.marioskate.android.AndroidLauncher"
android:label="@string/app_name"
android:screenOrientation="sensorLandscape"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Now my game can flip when I rotate my phone. 现在,当我旋转手机时,游戏可以翻转。 THe problem i have is that when the phone is flipped, the accelerometer value is also flipped..
我的问题是,当手机翻转时,加速度计值也会翻转。
How can I find out which android landscape orientation is ? 我如何找出哪个android横向?
I can't comment because of low rep. 由于声望低,我无法发表评论。 (previous was just converted to comment)
(以前只是转换为评论)
So now I know what you want, I didn't understand you before. 所以,现在我知道您想要什么了,我以前不了解您。 Try this:
尝试这个:
WindowManager mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
Display display = mWindowManager.getDefaultDisplay();
int rotation = display.getRotation();
Check the degree with Surface.ROTATION_0
(no rotation), Surface.ROTATION_90
, Surface.ROTATION_180
, or Surface.ROTATION_270
. 使用
Surface.ROTATION_0
(不旋转), Surface.ROTATION_90
, Surface.ROTATION_180
或Surface.ROTATION_270
。
See also here: http://developer.android.com/reference/android/view/Display.html#getRotation() and here http://developer.android.com/reference/android/view/Surface.html 另请参见此处: http : //developer.android.com/reference/android/view/Display.html#getRotation()和此处http://developer.android.com/reference/android/view/Surface.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.