我在玩游戏,方向是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>
现在,当我旋转手机时,我的游戏可以翻转。
我的问题是,当手机翻转时,加速度计值也会翻转。
我如何找出哪个android横向?
最佳答案
由于声望低,我无法发表评论。 (以前只是转换为评论)
所以,现在我知道您想要什么了,我以前不了解您。尝试这个:
WindowManager mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
Display display = mWindowManager.getDefaultDisplay();
int rotation = display.getRotation();
用
Surface.ROTATION_0
(不旋转),Surface.ROTATION_90
,Surface.ROTATION_180
或Surface.ROTATION_270
检查度数。另请参见此处:http://developer.android.com/reference/android/view/Display.html#getRotation()和此处http://developer.android.com/reference/android/view/Surface.html
关于java - Android-获取传感器横向方向,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23857692/