VLeonovs
VLeonovs

Reputation: 2251

how to arrange views in the layout

What is the best approach to arrange four views in layout ?

In portrait mode I would like:

On screen rotation to landscape I would like to change layout with animation to

How I should to arrange these views ? I'm thinking about 2 LinearLayout's and to change after roatation to one LinearLayout with horizontal orientation.. Or GridLayout ?

Upvotes: 2

Views: 152

Answers (2)

Clement Osei Tano
Clement Osei Tano

Reputation: 832

Just use two different layouts and create a refs.xml file in your nornal values folder, if you don't have one already, in that do something like;

<item name="plus_buttons" type="layout">@layout/plus_buttons_small_grid</item>

And then for screenwidths that you think the horizontal arrangement will fit perfectly, say 600dp, create a folder called values-sw600dp in your res directory and do something in another refs.xml in that folder like this;

<item name="plus_buttons" type="layout">@layout/plus_buttons_large</item>

With this you have two layout files that are independent of each other and work for all the desired screen widths

Upvotes: 0

Martin Pfeffer
Martin Pfeffer

Reputation: 12637

I would provide two layout files. The portrait has 3x LinearLayout

v

 -h

 -h

and landscape just one horizontal.

In terms of performance you should not fear a difference.

Upvotes: 1

Related Questions