1

虽然我创建了一个layout-land文件夹,但当方向更改为横向时,我的应用程序仍显示纵向布局。

我的问题在于我最初Activity的问题,其他活动似乎在横向模式下运行良好。

我的清单如下:

<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="14" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<supports-screens
    android:anyDensity="true"
    android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Black.NoTitleBar"> 

    <activity
        android:configChanges="keyboardHidden|orientation"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>


     <activity 
         android:configChanges="keyboardHidden|orientation"></activity>
     <activity
         android:configChanges="keyboardHidden|orientation"></activity>
     <activity 
         android:configChanges="keyboardHidden|orientation"></activity>
    <activity 
         android:configChanges="keyboardHidden|orientation"></activity>      
         <activity 
         android:configChanges="keyboardHidden|orientation"></activity>
4

1 回答 1

1

You'll need to remove the attribute android:configChanges from your manifest for the activities that you want to respond to the layout files in your layout-land folder.

When you specify android:configChanges="orientation" (along with the keyboard events), you're telling Android that you the developer are going to handle the orientation changes, and the system should not destroy and recreate the Activity.

This behavior is contrary to the default, which is to destroy an Activity, and recreate it with proper resources according to the current orientation.

于 2012-08-23T15:54:32.340 回答