admin管理员组文章数量:1399329
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:
本文标签: androidConstraintLayout Flow is not wrapping views as expectedStack Overflow
版权声明:本文标题:android - ConstraintLayout Flow is not wrapping views as expected - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744209699a2595362.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论