Put views in an Android layout with automatic line break
The Flexbox library from Google does exactly this:
Add the dependency to app/build.gradle:
dependencies {
implementation 'com.google.android:flexbox:2.0.1'
}
Usage of the layout:
<com.google.android.flexbox.FlexboxLayout
app:flexWrap="wrap">
<View/>
<View/>
<View/>
<View/>
</com.google.android.flexbox.FlexboxLayout>