将textView对齐到左边缘,其宽度可以增长。将右侧的其他textView对齐在一行中。
当左textView
宽度增加时,希望将右侧textView下推到下一行:
[AAA] [BBB]
当剩下一个宽度增长时:
[AAA AAA AAA AAA AAA]
[BBB]
想看到一些使用ConstraintLayout
的样本自动将右侧项目推到下一行,但无法找到任何。
它可以与ContraintLayOut
,或任何人都知道一些样本吗?
AFAIK,从一条线到另一条线的流动视图不是ConstraintLayout
可以做的事情。然而,FlexboxLayout
可以很容易地做到这一点。
Here是该技术的初步介绍。 Play商店中还有一些很好的应用程序可以使用布局。
FlexboxLayout可以解释为高级LinearLayout,因为两个布局都按顺序对齐其子视图。 LinearLayout和FlexboxLayout之间的显着区别在于FlexboxLayout具有包装功能。
我知道我参加派对的时间已经很晚了,但对于那些仍然赞同这个问题的人来说,截至今天,ConstraintLayout
2.0(刚刚在beta1中推出)支持一个名为ConstraintHelper
的新Flow
,使用它可以在ConstraintLayout
中满足您的特定要求。
你可以像这样使用com.google.android.material.chip.ChipGroup
<com.google.android.material.chip.ChipGroup
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/title">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="aaaaaaa"
android:textSize="10sp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="bbbbbb"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="cccccccc"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="fffffffff"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hhhhhhh"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="trtr"/>
</com.google.android.material.chip.ChipGroup>
在搜索并得出结论之后,ConstraintLayout将展平布局的视图层次结构以避免嵌套,以优化视图层次结构。因此@Cheticamp指出“ConstraintLayout没有那种特殊能力”。所以关闭这个问题。