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.
I have created two layout files (in res/layout and res/layout-land) for my application. But
Share
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, removeandroid: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()checkmy answer herefor getting it working.