Different design for landscape and portrait orientation android

Adarsh H S picture Adarsh H S · Oct 8, 2012 · Viewed 20.8k times · Source

Can we have a different xml for landscape and different xml for portrait orientation?

I am working on a simple app, have few buttons and textviews, the xml looks good in portrait, But with same xml when I check the landscape orientation, design doesn't look good.

Any suggestions are appreciated.. Thank you.

Answer

Kartik Domadiya picture Kartik Domadiya · Oct 8, 2012

Yes ofcourse.

You will have to create two versions of xml files and put in layout-port and layout-land folder inside res folder.

eg :

res/layout [Portrait Mode; default]
 main.xml
res/layout-land [Landscape Mode]
 main.xml 

You can refer further more on the same at http://developer.android.com/training/basics/supporting-devices/screens.html