ConstraintLayout可以帮助将右侧项目流到下一行吗? [英] can ConstraintLayout help to flow the right side item to next line?
问题描述
左下角有一个textView,它的宽度可能会增加.右边有一些其他textView可以单行对齐.
Having a textView alight to left edge, its width could grow. Having some other textView in its right align in single line.
当左侧textView
宽度增大时,希望将右侧的textView下推到下一行:
When the left textView
width grows, would like the right textView to be pushed down to next line:
[AAA] [BBB]
当左侧宽度增加时:
[AAA AAA AAA AAA AAA]
[BBB]
使用ConstraintLayout
会看到一些示例,该示例会自动将右侧项目下推至下一行,但找不到任何示例.
Thought seeing some sample using ConstraintLayout
to automatically push the right side item to next line down, but couldnt find any.
它可以与ContraintLayOut
一起使用,或者有人知道一些示例吗?
It is doable with ContraintLayOut
, or anyone knows some sample to do it?
推荐答案
更新:以下答案仍然有效,但是从 ConstraintLayout 2.0开始,使用 Flow 帮助器.有关示例,请参见此堆栈溢出答案.
Update: The answer below is still valid, but as of ConstraintLayout 2.0 it may be better to use the Flow helper. See this Stack Overflow answer for an example.
AFAIK,将视图从一行移到另一行不是ConstraintLayout
所能做的.但是,FlexboxLayout
可以很轻松地完成此操作.
AFAIK, flowing views from one line to the next is not something that ConstraintLayout
can do. It is, however, something that FlexboxLayout
can do very easily.
此处是最初的介绍技术. Play商店中还提供了一些不错的应用程序,可以与布局进行互动.
Here is an initial introduction to the technology. There are also a few good apps on the Play store to play around with the layout.
FlexboxLayout可以解释为高级LinearLayout,因为这两种布局都按顺序对齐其子视图. LinearLayout和FlexboxLayout之间的重要区别在于FlexboxLayout具有包装功能.
FlexboxLayout can be interpreted as an advanced LinearLayout because both layouts align their child views sequentially. The significant difference between LinearLayout and FlexboxLayout is that FlexboxLayout has a feature for wrapping.
这篇关于ConstraintLayout可以帮助将右侧项目流到下一行吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!