Portrait and Landscape Layouts

While you are developing your mobile application, you always have to think in the user side, and how your application will provide fast and quality results (those could be data, screens, services, etc) for the user. Not only think in HOW, but envision if is going to be that effectively. Now we got the point. One factor that always influences users of the way they see a game or an application is the way of the screen is disposed.

When you are developing your application, Android framework make it easy for you. You just do your application, and when the cellphone go to landscape, is a different the way you have thought. And everything could be changed of place, it would be not aligned as you designed and a headache just starts.

I will show will, a little application and the way it behaves in Portrait and Landscape. And a way to define your Landscape as you wish.

Here, we have a simple application, a Temperature Converter:

Here. The Layout is set up to Vertical. At this point no problem. But when you turn to landscape, it follows what you have done.

You could this using LinerLayout, TableLayout whichever you want is fine.

Here, I just used the LinearLayout.





See. It just followed what you have set up for the application.

However if you wish to be different in portrait, or landscape, what do you do?






Here we have all the packages that are created when you just created the project.

You see the layout/main.xml , right?

So we should add another layout, the landscape layout to have a “dedicated” layout to landscape. How do we do that? simple!!

So, just create a folder called layout-land to define

your layout and create the main.xml inside.

This main.xml, could be totally different, you could

include more features as well.

But if you want just change the layout to other way

you think is better for the user, you do it.




Here, just a new Landscape layout:

If you noticed, the TextView is different, and the way that components are disposed on the screen too.

Here, I just used other type of Layout, the TableLayout.

This means, you can do your own screens in different ways, or use different resources/components to cause a better impression and usability for the user.

Some mobile applications have better view in Portrait, while others have better view in Landscape. It means, depend of the goal of the application. What it is going to show to the user and if what is being shown is the best way to do it. Sometimes, the way the components are disposed is the key, though. Facilitate the view to the user is always welcome. As I said, it could vary from the simplest application to the most complex.