How to develop Android application for tablet in landscape mode and in portrait mode for Phones?
Asked
Active
Viewed 1,022 times
-4
-
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: [Stack Overflow question checklist](http://meta.stackexchange.com/questions/156810/stack-overflow-question-checklist) – reto Dec 13 '13 at 08:19
4 Answers
0
You can provide alternate layouts. Create folder /res/layout-land
and put your layout xml file in it.

Aniket Thakur
- 66,731
- 38
- 279
- 289
0
Now to make your App screen to work in both orientations as expected, please follow the below steps:
- As shown in the below screenshot, under “res” folder, create a new folder with the name “layout-land”, -land appended for landscape orientation.
- For landscape orientation, create layout xml under “layout-land” folder with the same name as of the layout xml under “layout” folder. Note that name of the xml file in layout and layout-land folder should be same.
Screen orientation–Portrait / Landscape
and even try to mention this
<supports-screens android:resizeable=["true"| "false"]
android:smallScreens=["true" | "false"]
android:normalScreens=["true" | "false"]
android:largeScreens=["true" | "false"]
android:xlargeScreens=["true" | "false"]
android:anyDensity=["true" | "false"]
android:requiresSmallestWidthDp="integer"
android:compatibleWidthLimitDp="integer"
android:largestWidthLimitDp="integer"/&rt;

vinay Maneti
- 1,447
- 1
- 23
- 31
-1
Disable the device's orientation sensor by setting the attribute in the activity tag in the manifest file like this:
android:screenOrientation="nosensor"
When you run your app, by default portrait orientation is set for phones and landscape for tablets(and hence it'll select the xml file from layout-xlarge-land
). And since you've set an orientation lock, it remains in this orientation.

Dev
- 6,628
- 2
- 25
- 34