tags:

views:

38

answers:

2

is it possible to change the layout of the app when the orientation of the screen changes from portrait to landscape ? I mean linking the app to two different .xml layout files for each landscape and portrait? or maybe is it possible to change placement of 2 views ? like... i want a button to be below the textview in portrait mode but i want them side by side in landscape mode... :/ please help...

A: 

Yep, it's one of the basic layout tips, might want to read through the tutorials on developer.android.com.

For this instance, just put the separate layout in res/layout-land (you'll have to make a new folder) with the same name as the portrait layout.

kcoppock
can you please give me the link ? i can find it :/
Well now I just feel bad; I can't find it on the dev site either now. However, Chris's answer above should help, and also this tutorial may help:http://wiresareobsolete.com/wordpress/2009/12/android-layouts-supporting-orientation/
kcoppock
+1  A: 

Yes its actually very easy. In your res folder you have a layout folder with you layouts. Make a layout-land folder for your landscape layouts. The .xml files should have the same name as their counter parts in the layout folder. Android will automatically pick the right one at runtime during onCreate in your activities.

/res/layout - default if none exist for a particular condition /res/layout-land - landscape layouts.

Note, you do not need to create duplicates if nothing is different for a particular layout, it will just use the default.

smith324