0

Is there any control either in Android framework, or support libraries that allows me to display the fixed amount of other controls (lets say buttons) inside it and divide those other controls in rows if it needs to be?

Let me explain what I'm looking for with an example. Lets say I have 5 buttons named "A", "B", "C", "D" and "E". Now I want to put these buttons in some type of "ViewGroup" that will automatically place those buttons one after another depending on their visibility. So if I will set say, that there should be only at max 3 buttons in one row and all buttons are visible I should see this:

"A" "B" "C" "D" "E"

That's because only 3 buttons can be in a single row and so the parent "ViewGroup" moves the other buttons to the next row automatically. However if I hide say "B" button (Set its visibility to Gone) what I would expect to see is:

"A" "C" "D" "E"

It is important there is no fixed width set on the button controls as I want the size to be independent of the ppi of the screen. The width size of the buttons should be divided uniformly for them just like with the "weight" attribute inside LinearLayout.

azizbekian
  • 60,783
  • 13
  • 169
  • 249
Lucas
  • 3,521
  • 3
  • 27
  • 39
  • I'm a little confuse, you wrote you should see 3 buttons in one row but you wrote five (A-E)... anyway in `GridLayout` you have `rowCount` (and `columnCount`) properties, try to play with them. here is an example: http://stackoverflow.com/questions/32193484/how-do-i-layout-two-edittexts-side-by-side-to-each-other-in-a-gridlayout/32196505#32196505 – AsfK Aug 30 '15 at 08:07
  • Thank you for answer. There was a problem with formatting that I didn't notice. Of course I meant "A" "B" "C"; "D" "E" and "A" "C" "D"; "E" where ";" character means new row. GridView will not help because it doesn't move elements when you hide some of them. – Lucas Aug 30 '15 at 15:44
  • I don't know how to solve your problem :( but to fix the format do double enter in order to receive new line – AsfK Aug 31 '15 at 05:26

1 Answers1

1

This may be easily implemented with FlexboxLayout. Basically, it is a powerful FlowLayout, a type of layout that other frameworks own. FlexboxLayout is developed and maintained by Google.

enter image description here

azizbekian
  • 60,783
  • 13
  • 169
  • 249