Search code examples
androidandroid-layoutandroid-custom-viewandroid-button

Custom layout to accommodate variable number of buttons of variable width


I have a layout with a fixed width and variable height. In this layout I want to have a variable number of buttons of variable width but fixed height. If the sum of the widths of the buttons is greater than the total width of the layout then the buttons should spillover to the next row. The number of rows is also variable. How to ensure the extra buttons spill over to the next row?

Desired View Result


Solution

  • The library FlowLayout by Blazsolar does the above. It is very simple and easy to use.

    https://github.com/blazsolar/FlowLayout