-4

How to develop Android application for tablet in landscape mode and in portrait mode for Phones?

Cœur
  • 37,241
  • 25
  • 195
  • 267
shrikant
  • 11
  • 3
  • 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 Answers4

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:

  1. As shown in the below screenshot, under “res” folder, create a new folder with the name “layout-land”, -land appended for landscape orientation.
  2. 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;

In this manner image provider

vinay Maneti
  • 1,447
  • 1
  • 23
  • 31
0

You should have to check device type programmatically (link). If the device is mobile then lock app orientation to portrait otherwise lock orientation to landscape mode.(link) And you need two layout folders - layout and layout-land.

Community
  • 1
  • 1
Roshni
  • 256
  • 1
  • 4
  • 16
-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