erdemgc
erdemgc

Reputation: 1721

Having Difficulty with Landscape Layouts

Although I have created a layout-land folder, my app is still displaying the portrait layout when orientation is changed to landscape.

My problem is in my initial Activity, the other Activities seem to be working well in landscape mode.

My manifest is as follows:

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

Upvotes: 1

Views: 97

Answers (1)

wsanville
wsanville

Reputation: 37516

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.

Upvotes: 1

Related Questions