我通过添加"super.setIntegerProperty("splashscreen",R.drawable.splash)在我的phonegap应用程序中添加了一个启动画面;" 在DefaultActivity中的super.loadURL ...行之前的行.
有没有办法只将锁定屏幕的方向锁定到纵向而不锁定整个应用程序?
经过多次搜索,我发现解决闪屏方向的正确方法是使用此代码将两个图像管理到您的MainActivity
if (getResources().getConfiguration().orientation == 2) {
super.setIntegerProperty("splashscreen", R.drawable.splashlandscape);
Log.d("Orientation", "Landscape");
}
else {
super.setIntegerProperty("splashscreen", R.drawable.splashportrait);
Log.d("Orientation", "Portrait");
}
Run Code Online (Sandbox Code Playgroud)
如果您使用的是最新版本的 PhoneGap (DroidGap) 或 Apache Cordova,您可以通过更改 Android.xml 文件中的 screenOrientation 来强制屏幕方向为横向。生成的 DroidGap“实例化活动”应如下所示:
<activity
android:name="org.apache.cordova.DroidGap"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="landscape"
>
<intent-filter>
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4532 次 |
| 最近记录: |