android - ConstraintLayout Flow is not wrapping views as expected - Stack Overflow

I'm maintaining legacy app which is still using XMLs and oldschool Views.I have androidx.constrai

I'm maintaining legacy app which is still using XMLs and oldschool Views.

I have androidx.constraintlayout.helper.widget.Flow component which has constraint_reference ids to other Views.

Those other views visibility is set to GONE or VISIBLE based on state of the item.

What is issue in this Flow component is how item views are displayed.

Max I can display in single row is 3 items. If 4th one is visible, it should start in next row from start/left. This first usecase is working correctly. But when I have 1 or 2 items, they should appear in single row starting from start/left. But they are currently centered to the middle of the screen width. In LayoutInspector Flow view is centered in the middle (despite match_parent width is set)

Not sure what is wrong and why is this behavior happening for 2 or 1 item.

Code:

<androidx.constraintlayout.helper.widget.Flow
        android:id="@+id/flowHelper"
        style="@style/InfoFlow"
        android:layout_width="match_parent"
        android:layout_marginTop="20dp"
app:constraint_referenced_ids="viewTimerInfo,viewScheduleInfo,viewBreakInfo,viewMaintenanceInfo"
        app:layout_constraintTop_toBottomOf="@+id/txtStoreType"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintBottom_toTopOf="@id/divider"/>

Style:

  <style name="InfoFlow">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="flow_wrapMode">chain</item>
        <item name="flow_maxElementsWrap">3</item>
        <item name="flow_horizontalStyle">packed</item>
        <item name="flow_horizontalBias">0</item>
        <item name="flow_horizontalGap">@dimen/padding_default</item>
        <item name="flow_horizontalAlign">start</item>
        <item name="flow_verticalStyle">spread</item>
        <item name="flow_verticalBias">0</item>
        <item name="flow_verticalGap">@dimen/padding_small</item>
        <item name="flow_verticalAlign">center</item>
    </style>

Behavior:

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744209700a4563277.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信