1

Is it possible in Android to insert an image in a TextView and align the text like this image below ?

Desired result

Thank you in advance!

antoniom
  • 3,143
  • 1
  • 37
  • 53
  • This has been asked before on stackoverflow. A pretty good answer is given here: http://stackoverflow.com/a/8463221/475142 (No, it certainly isn't pretty) – Mark D Mar 26 '12 at 22:00

1 Answers1

2

If I remember correctly there are really only two ways to do this in android.

  1. Create an HTML asset and inject your data to the webview. (Obviously not what you are looking for.

  2. Create a Spannable object with an ImageSpan.

Route two is probably more what you are looking for.

EDIT Looking further into it it appears that ImageSpans can only Bottom or Baseline-Align with the text. And since you are specifically asking about a TextView. No what you are asking is not possible with a TextView from my understanding.

Bill
  • 413
  • 2
  • 10
  • Thanks for your answer. While I was searching for this, I came across `ImageSpan` and found the limitations you mention. I already thought of option #1, but as this is not the most elegant way, do you have in mind something better ? – antoniom Mar 26 '12 at 21:33
  • @antoniom Unfortunately Ive not seen a more elegant solution. We had done a news type application that had this exact requirement and it was just way easier to do it in a webview than any other method. Its not ideal and really begs the question can your product be redesigned for mobile paradigms as opposed to feeling like a website or newspaper? – Bill Mar 27 '12 at 05:08