在Android PhoneGap中更改方向时,启动画面未更改

3
我尝试设置横向和纵向两个启动界面。为此, 我在我的活动类中编写了以下代码:
if (getResources().getConfiguration().orientation == 2) {
            super.setIntegerProperty("splashscreen", R.drawable.equipsplashscreen);
            Log.d("Orientation", "Landscape");
        }
        else {
            super.setIntegerProperty("splashscreen", R.drawable.splashscreen);
            Log.d("Orientation", "Portrait");
        }

屏幕显示方式会根据方向而改变,但问题在于...加载时屏幕不会随之改变(例如,我以竖屏模式启动应用程序,在加载闪屏时将方向从竖屏更改为横屏,此时我的横屏图片未能加载...只有竖屏图片被更改为横屏样式)。
我正在使用cordova-1.8.0和jquery-1.7.1。
我该如何解决这个问题...谢谢。
1个回答

0
在Android中,我们需要像这样覆盖onConfigurationChanged方法。
@Override
public void onConfigurationChanged(Configuration newConfig) {

    super.onConfigurationChanged(newConfig);
    if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
        setContentView(R.layout.splashscreen);
        init();
    } else if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
        setContentView(R.layout.splashscreen);
        init();
    }
}

在清单文件中添加一个标签,像这样

<activity
    android:name=".YourActivity"
    android:configChanges="orientation|keyboardHidden"
    android:windowSoftInputMode="stateAlwaysHidden|adjustResize|adjustPan" />

现在检查一下PhoneGap的要求,因为我不熟悉PhoneGap,我给你提供在Android中已经做了什么的提示。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接