Reputation: 75
Currently, i develop a android application. In my activity, i would like to place my elements according to their size. i explain : i have 3 LinearLayout in a GridLayout like this :
GridLayout (2,2, horizontal) allow to put the LinearLayouts like this :
I would like to do the same, but no with GridLayout(2,2,horizontal), but just according to the size of the element.
For example, if the screen is large, it's possible to have the 3 LinearLayout on the same line and inversely if the screen is small, juste 1 LinearLayout by line.
I hope I have been clear, Thanks in advance.
Upvotes: 3
Views: 68
Reputation: 11776
Yes, of course you can do.
You need to create different layout directory for different density devices.
For example layout-ldpi, layout-hdpi, etc. and define the required kind of layout inside these.
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
And inside the different my_layout.xml file define either one, two or three linearlayouts you need.
Upvotes: 0
Reputation: 3274
Try these instead of gridlayout
https://github.com/blazsolar/FlowLayout
Upvotes: 0
Reputation: 12002
This layout would be a "FlowLayout" which doesn't exist in standard.
But there are some open-source implementations of it around :
You should take a look at
https://github.com/ApmeM/android-flowlayout
or
https://github.com/blazsolar/FlowLayout
Upvotes: 2