在平板电脑上旋转时App不会停留在景观中... Android 4.0

时间:2012-02-15 14:55:44

标签: android sdk webview orientation

我知道这里有很多问题。我一直在Google上查看数百页,但无法确定为什么我的应用不会保持横向模式:

清单:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="-------------"
  android:versionCode="1"
  android:versionName="1.0">
<uses-sdk android:minSdkVersion="10" />

<uses-permission android:name="android.permission.INTERNET"/>

<application android:icon="@drawable/icon" android:label="@string/app_name"
    android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
    android:configChanges="keyboardHidden|orientation"
    android:screenOrientation="landscape"   >
    <activity android:name="---------Activity"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

</application>

main.xml中:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:configChanges="keyboardHidden|orientation"
    android:screenOrientation="landscape"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<WebView android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:configChanges="keyboardHidden|orientation"
    android:screenOrientation="landscape"
  android:id="@+id/mainWebView">
 </WebView>

这只是一个带有一个WebView的应用......

2 个答案:

答案 0 :(得分:1)

android:screenOrientation="landscape"添加到AndroidManifest中的活动。例如:

<activity android:name=".SomeActivity"
android:label="@string/app_name"
android:screenOrientation="landscape">

答案 1 :(得分:1)

您应该为每个活动设置android:screenOrientation。相反,你是在应用程序上做的。 另外,screenOrientation和configChanges对布局xml文件没有任何作用。