Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I do something like a FlowLayout in Android?

Tags:

android

How can I do something like a FlowLayout in Android?

like image 942
Adham Avatar asked Dec 17 '10 19:12

Adham


People also ask

What is Android FlowLayout?

A FlowLayout for Android, which allows child views flow to next row when there is no enough space. The spacing between child views can be calculated by the FlowLayout so that the views are evenly placed.

What is Android XML layout?

Using Android's XML vocabulary, you can quickly design UI layouts and the screen elements they contain, in the same way you create web pages in HTML — with a series of nested elements. Each layout file must contain exactly one root element, which must be a View or ViewGroup object.

What is a flow layout?

A flow layout arranges components in a directional flow, much like lines of text in a paragraph. The flow direction is determined by the container's componentOrientation property and may be one of two values: ComponentOrientation.


1 Answers

You should use FlexboxLayout with flexWrap="wrap" attribute.

<com.google.android.flexbox.FlexboxLayout       android:layout_width="match_parent"       android:layout_height="wrap_content"       app:flexWrap="wrap">  <!-- contents go here -->  </com.google.android.flexbox.FlexboxLayout> 

For build instructions, see the github repo.

implementation 'com.google.android:flexbox:2.0.1' 

visual representation of FlexboxLayout More about this - https://android-developers.googleblog.com/2017/02/build-flexible-layouts-with.html

like image 180
arsent Avatar answered Sep 25 '22 21:09

arsent