SANDHYA
SANDHYA

Reputation: 791

Screen orientation in android

I have created two layout files (in res/layout and res/layout-land) for my application. But it is not displaying the proper layout file when i change the device orientation. It just displays the same layout file (res/layout) in both the modes. Why it is not picking up the landscpe mode layout file in landscape mode? Also i have added android:configChanges="keyboard|orientation" to my activity in manifest. What else i have to do? I'am a newbie to android app development.

Upvotes: 0

Views: 348

Answers (2)

5hssba
5hssba

Reputation: 8079

You should not add this.

android:configChanges="keyboard|orientation"

in your manifest.. because it is not allowing the call for onConfigurationchanged method... which is responsible for handling the orientation changes... remove that line from you manifest and it should work...

Upvotes: 1

Lalit Poptani
Lalit Poptani

Reputation: 67286

If you are adding added android:configChanges="keyboard|orientation" in Manifest file it won't change the layout, because by adding this attribute your Activity is not re-created again so it displays the same layout as in portrait mode. So, remove android:configChanges="keyboard|orientation" from Manifest file to get it working.

If you want that your Activity should not be created again and also it should change the layout when your orientation changes you have to add code for changing the layout manually in onConfigurationChanged() check my answer here for getting it working.

Upvotes: 2

Related Questions