Reputation: 61
I tried to use new android Flow layout. https://developer.android.com/reference/android/support/constraint/helper/Flow. I have this screen, items in flow layout and expander (now is open). When expander is closed i want to place only first line (4 items).
My xml flow layout
<androidx.constraintlayout.helper.widget.Flow
android:id="@+id/fr_mail_viewer_attachments_flow"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
app:flow_horizontalBias="0"
app:flow_horizontalGap="8dp"
app:flow_horizontalStyle="packed"
app:flow_verticalBias="0"
app:flow_verticalGap="8dp"
android:layout_marginEnd="8dp"
app:flow_wrapMode="chain"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/fr_mail_viewer_attachments_expander"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
I tried to use app:flow_maxElementsWrap="1"
and it didn't help me
Can anyone help me or share some resourses about flow layout?
Upvotes: 3
Views: 3090
Reputation: 41
In your case, you want to wrap after 4 elements as I see in your picture. You should add app:flow_maxElementsWrap="4" to your Flow widget. Also, keep in mind that you can set the orientation to the flow widget to control how items in a chain are laid out:
<androidx.constraintlayout.helper.widget.Flow
android:id="@+id/fr_mail_viewer_attachments_flow"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
android:orientation="vertical"
app:flow_horizontalBias="0"
app:flow_horizontalGap="8dp"
app:flow_horizontalStyle="packed"
app:flow_verticalBias="0"
app:flow_verticalGap="8dp"
android:layout_marginEnd="8dp"
app:flow_wrapMode="chain"
app:flow_maxElementsWrap="4"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/fr_mail_viewer_attachments_expander"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Upvotes: 2