问题
I am creating an android game where every activity is set to be in landscape in the xml manifest file.
However, sometimes when going to a new activity it flashes up in portrait for a second before correcting to landscape.
Does anyone have any generic reason why this might be?
It happens when exiting the level completion screen too early which uses a ScheduledFuture
Thanks Andy
EDIT (Manifest):
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.appsolutely.sheepherder"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.appsolutely.sheepherder.Main"
android:label="@string/app_name"
android:screenOrientation="landscape" >
</activity>
<activity
android:name="com.appsolutely.sheepherder.Game"
android:label="@string/title_activity_game"
android:screenOrientation="landscape" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.appsolutely.sheepherder.LevelSelect" />
</activity>
<activity
android:name="com.appsolutely.sheepherder.LevelSelect"
android:label="@string/title_activity_level_select"
android:screenOrientation="landscape" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.appsolutely.sheepherder.Main" />
</activity>
<activity
android:name="com.appsolutely.sheepherder.Splash"
android:label="@string/app_name"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.appsolutely.sheepherder.Plague"
android:label="@string/title_activity_plague"
android:screenOrientation="landscape" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.appsolutely.sheepherder.Main" />
</activity>
</application>
回答1:
Try to add screenOrientation to your manifest:
<activity android:screenOrientation="sensorLandscape" ...>
I suggest to use sensorLandscape
so the user can choose if the divice is rotated to the right or the left.
来源:https://stackoverflow.com/questions/14691443/activity-flashes-up-in-portrait-before-switching-to-landscape