I want to use ConstraintLayout's Flow widget but when I search I can't find any example about using Flow widget programmatically.
How can I set constraint_referenced_ids programmatically?
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.constraintlayout.helper.widget.Flow
android:layout_width="0dp"
android:layout_height="wrap_content"
app:constraint_referenced_ids="text1,text2"
app:flow_horizontalBias="0"
app:flow_horizontalGap="10dp"
app:flow_horizontalStyle="packed"
app:flow_verticalBias="0"
app:flow_wrapMode="chain"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
This works for me:
My custom
PerkFlowclass:my
xml:The setup of the PerkFlow in Fragment:
Hope this helps!
And one more thing: if you call this again (in RecyclerView item, or new data arrives), don't forget to clear the parent view or the elements will be duplicated. I can send that code too if needed.