How to place items according to their size?

I am currently developing an android app. In my activity, I would like to place my items according to their size. I'll explain: I have 3 LinearLayout in GridLayout like this:

enter image description here

GridLayout (2,2, horizontal) lets you place LinearLayouts like this:

enter image description here

I would like to do the same, but not with a GridLayout ( 2 , 2 , horizontally), but only according to the size of the element.

For example, if the screen is large, there may be 3 LinearLayout on one line, and vice versa, if the screen is small, juste 1 LinearLayout by line.

Hope I was clear, thanks in advance.

+3


source to share


3 answers


This layout will be "FlowLayout" which doesn't exist in the standard.

But there are some open source options:

You should take a look at



https://github.com/ApmeM/android-flowlayout

or

https://github.com/blazsolar/FlowLayout

+2


source


Yes, of course you can.

You need to create a different layout directory for different density devices.

For example layout-ldpi , layout-hdpi , etc. and define the type of layout you need within them.



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 another file my_layout.xml specify one, two or three linear passes you need.

0


source


0


source







All Articles