0

Is there some way to set up a LinearLayout or a ConstraintLayout to put as many views in a linear chain and simply start a new row as soon as not all views fit into the current row?

Like following:

Item1 - Item2 - Item3 - Item4
Item5 - Item6 - Item7 - Item8
Item9 - Item10

Or on a larger screen

Item1 - Item2 - Item3 - Item4 - Item5
Item6 - Item7 - Item8 - Item9 - Item10

As far as I know LinearLayout can't do this at all and ConstraintLayout does not support such line breaks inside a chain.

Any other way to get what I want? (Not programmatically calculating available space and putting LinearLayouts inside a parent LinearLayout container, I know how to do this - I'm looking for a more beautiful solution).

prom85
  • 16,896
  • 17
  • 122
  • 242
  • 1
    https://stackoverflow.com/a/38472370/8114201 – VolkanSahin45 Jul 01 '19 at 19:07
  • This weblike behaviour is avilable on flexbox layout https://github.com/google/flexbox-layout – cutiko Jul 01 '19 at 19:09
  • I want to avoid a custom view for this. @VolkanSahin45, the RV based solution looks interesting, thanks, I'll check this out. I did not think about an RV for some case... – prom85 Jul 01 '19 at 19:13

0 Answers0