How to develop Android application for tablet in landscape mode and in portrait mode for Phones?
How to develop Android application for tablet in landscape mode and for phone in portrait mode
1k views Asked by shrikant At
4
There are 4 answers
0
On
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.
0
On
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;
You can provide alternate layouts. Create folder
/res/layout-land
and put your layout xml file in it.