7

I would like to have a Layout for Views in Android that manages itself to use its empty space dynamically and EITHER puts the next view added right to the last view if it still fits OR breaks line and adds the view on the new line on the left...

Example:

||Name|LoooooongName|Ho      ||
||SuperLongName|NextLongname ||
||Bob|Sue|Martin|Richard|Joe ||
||Marvin|Homer|Ann-Marie     ||

Any clues? Thanks for your help!

1
  • just write a custom layout that do this Commented Mar 1, 2011 at 15:42

1 Answer 1

1

This is possible, but not easy. You will have to create a custom layout. Check out the source code to LinearLayout for an example, specifically layoutHorizontal().

You will override ViewGroup.onLayout(). Inside it you will check the size of your children using View.getMeasured{Width,Height}(), making sure they can fit on the line or move to the next.

Sign up to request clarification or add additional context in comments.

1 Comment

Puh, so there is really the need to write a whole Layout on one's own? Can't imagine that does not exits already...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.