views:

53

answers:

2

I can not find any related layout implementation in android build in layouts.

I found one implementation in this post, http://stackoverflow.com/questions/549451/line-breaking-widget-layout-for-android, but in that post's case, there is a precondition that the child's width is not wider than the parent's.

But in my case, the child's width is wider than the parent's. Like say, there is one textview and one image in the layout, the layout's width is 200, while the textview's whole width is 300, and the image's width is 50.

Any build-in implementation in android for this ? Or any suggestion about how to implement this layout by myself ?

Thanks.

A: 

But in my case, the child's width is wider than the parent's.

That is mathematically impossible.

Like say, there is one textview and one image in the layout, the layout's width is 200, while the textview's whole width is 300, and the image's width is 50.

That is mathematically impossible. Your layout's width has to be at least as large as its largest child.

CommonsWare
I am sorry maybe I don't make myself clear. When the parent's width is 200, the textview's width is 300 ( if the text is in one line ), so what I try to achieve is that there is two lines of text, one line is 200, the second is 100, and then follow the second line's text, there is a 50 wide image.
@user441316: Ah! Now I understand. That is not possible, AFAIK, even with a custom layout class.
CommonsWare
A: 

I found the solution, which is to use ImageSpan, and then invoked SpannableStringBuilder.setSpan method.