M.A.Murali
M.A.Murali

Reputation: 10158

Portrait, Landscape in Android app

I am designing with LinearLayout which is working for portrait but landscape it does arranged properly. I do not use x,y positions. If I change anything in xml it affects the design -- how do I design both portrait and landscape?

Upvotes: 1

Views: 1471

Answers (2)

ferostar
ferostar

Reputation: 7082

You can specify a layout-land folder, to put all your landscape layouts (duplicate them, but with little differences in order to they show properly in corresponding orientation). In order to avoid this, you should work with RelativeLayouts. But if it's too late and you don't want to change everything, you can create the mentioned folder and make the proper layout changes.

So you will have a

layout/activity.xml

and a

layout-land/activity.xml

If your app is big, it might become a pain to make every change two times, but it's not so bad.

Not recommended, but you can also avoid changing orientation by supporting only portrait orientation in your app: you would have to put "android:screenOrientation="portrait"" in your app's Manifest then.

Upvotes: 4

djg
djg

Reputation: 1283

You can define a second xml file that is the layout for the landscape version. That file must be named the same and placed in a layout-land folder:

i.e.

Portrait:

layout/main.xml

Landscape:

layout-land/main.xml

Upvotes: 1

Related Questions