I spent a fair amount of time doing the same thing.  Html.fromHTML is
helpful, but it seems to basically take each <img> tag it encounters
and add it to the textview like a character.  So you can have one line
of text to the left, and one line to the right, but you cant have
multiple lines of text on each side.

I used a similar hack.  I called measureText on the Paint attached to
the TextView, to estimate how much of a given CharSequence would fit
in a first textView adjacent to an image.  I then took the remaining
portion of the CharSequence and gave it to a TextView under the image.

http://developer.android.com/reference/android/graphics/Paint.html#measureText%28java.lang.CharSequence,%20int,%20int%29

This was ugly though because I needed the width of the ImageView and
it's container to be determined already.  It took more logic then I
had time for to try to get it to calculate it all properly.  I tried
browsing into the source for TextView

http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob_plain;f=core/java/android/widget/TextView.java

but didn't come away with too much of use.

Has anyone wrapped multiple lines of text around an image that is
multiple lines tall?

On Oct 20, 8:40 am, focuser <[email protected]> wrote:
> anyone could help?
>
> On Oct 17, 10:15 am, focuser <[email protected]> wrote:
>
> > Hi,
>
> > I know this has been brought up before, but I couldn't find a solution
> > yet.
>
> > I'd like to get the similar layout on an Activity as this html
> > fragment in a browser, basically making text wrapping around an image:
>
> > <img src="rainbow.gif" align="left">
> > bla bla bla bla bla
> > bla bla bla bla bla
> > bla bla bla bla bla
>
> > I tried the following but no luck yet:
> >  - None of the current layouts supports this.
> >  - a TextView and using Html.fromHTML, but that doesn't seem to
> > understand the "align" attribute -- No matter what "align" equals to,
> > it just places the image in the same line of the first line of text,
> > and never aligns multiple lines of text along side the image.  Styles
> > don't work either.
> >  - I looked up the doc of ImageSpan, but its verticalAlignment only
> > supports "bottom" and "baseline".  Should I use "baseline"?  I tried
> > it but seems no effect, maybe I'm missing something?
> >  - A hack: using two TextView, one to the right of the image, and
> > another below the image, and set the maxLines of the first TextView to
> > be approximately the height of the image.  But the problem is I
> > couldn't get the *last visible character* for the text.
>
> >  I don't want to use WebView since it seems to be too much overhead
> > for such a simple view.
>
> > Thanks.
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to