What you need is called FlowLayout
Use one of the libraries: FlowLayout or android-flowlayout
In the case of the first one, add FlowLayout
to the markup, and add the necessary number of your widgets to it, which should be transferred to another line if they do not fit
<com.wefika.flowlayout.FlowLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="start|top"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Lorem ipsum" /> <!-- тут ещё много вьюх --> </com.wefika.flowlayout.FlowLayout>
It turns out like this:

There is a container from Google's FlexboxLayout support libraries - a much more functional widget than FlowLayout