Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
530 views
in Technique[技术] by (71.8m points)

android - can ConstraintLayout help to flow the right side item to next line?

Having a textView alight to left edge, its width could grow. Having some other textView in its right align in single line.

When the left textView width grows, would like the right textView to be pushed down to next line:

[AAA]  [BBB] 

when left one width grows:

[AAA AAA AAA AAA AAA]

[BBB]

Thought seeing some sample using ConstraintLayout to automatically push the right side item to next line down, but couldnt find any.

It is doable with ContraintLayOut, or anyone knows some sample to do it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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, 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.

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 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...