'Wrap views (like wrapping text)

I woul like to wrap views (like buttons) inside another view (a button container). I'm not quite sure how to explain it, but an example would be the Stack Overflow tag box (when a question is asked) and the window is narrow. Tags roll over to the next line if they are too long.

Example images using Stack Overflow tag box.

Wide labels auto-flow across multiple lines:

enter image description here

Narrow labels self-distribute on a line:

enter image description here

I get a list of strings from a web service. I don't know how many elements it will have and if the texts will be long or short:

  • Example 1: "a", "b", "c". In this case there would be four buttons that would fit seamlessly on one line.
  • Example 2: "first text", "second text (long this time)", "short text", "another text", "one more text", "the last text".

The gray view is the container with specific width, and dynamic buttons in blue.

enter image description here

How can I do something like this?



Solution 1:[1]

I am not sure what you mean but you can check native-base Accordion component for that so you can place views in Accordion component. https://docs-v2.nativebase.io/Components.html#accordion-def-headref

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 atakulmert