本文介绍了切换为横向之前,活动以竖向闪烁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个android游戏,其中每个活动都在xml清单文件中设置为横向.

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?

使用ScheduledFuture太早退出关卡完成屏幕时会发生

It happens when exiting the level completion screen too early which uses a ScheduledFuture

谢谢安迪

编辑(清单):

    <?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>

推荐答案

尝试添加 screenOrientation 到您的清单:

Try to add screenOrientation to your manifest:

<activity android:screenOrientation="sensorLandscape" ...>

我建议使用sensorLandscape,以便用户可以选择将设备向右还是向左旋转.

I suggest to use sensorLandscape so the user can choose if the divice is rotated to the right or the left.

这篇关于切换为横向之前,活动以竖向闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 21:32