1) How would one go about altering/extending TextView to render inline images?
It seems that setText(Html.fromHtml(...image tags...)) might actually allow image insertion if set up correctly, but I haven't tried myself. Even if, I would still need fine grained control over the image drawing (my final goal is to display inline animated smiley images). So unfortunately a view based on WebKit or similar is not an option either.
2) As an alternative solution I thought of mixing TextViews and ImageViews (or more specifically, custom subclasses thereof which allow animation), but I'm not sure how I could achieve proper wrapping there (I'm fairly new to Android).
this tutorial should help you: http://techdroid.kbeanie.com/2010/06/textview-with-html-content.html
specifically this section of the tutorial ...
static ImageGetter imgGetter = new Html.ImageGetter() {
@Override
public Drawable getDrawable(String source) {
Drawable drawable = null;
drawable = Drawable.createFromPath(source); // Or fetch it from the URL
// Important
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable
.getIntrinsicHeight());
return drawable;
}
};
EDIT: found another tutorial, which I thought looked neater: http://androidjava.wordpress.com/2010/09/17/images-in-textview/
Does this text need to be editable, or just displayed? Another option might to be to render your content in a WebView and layout your text/images using straight html.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With