1

I want to have a photo in line with a paragraph of a text in my Android app. Like the photo below:

enter image description here

For that, I have used a SpannableString with an ImageSpan:

ImageSpan is = new ImageSpan(mContext, R.drawable.image);
SpannableString text = new SpannableString("This is a sample text");
text.setSpan(is, 0, 10, 0);
myTextView.setText(text);

However, the image is placed only on the first line of the paragraph.

How can I achieve this layout? And please note that later I would like to download the image in the background (lazy loading in a ListView).

Saba Jamalian
  • 750
  • 2
  • 10
  • 24

1 Answers1

3

FlowTextView looks like it should have what you want, though I have not tried it.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks. Yes it looked like to be what I wanted. I just tried it but I have a couple of problems with this library: 1. Performance: When used in a ListView, scrolling becomes less smooth even when there is no Image inside it. I'm pretty sure 'FlowText' is causing the problem because if I replace it with TextView, everything is smooth. 2. Functionalities of ListView such as 'OnItemClickListener' don't work. So, is there any alternative library to 'FlowTextView'? – Saba Jamalian Aug 05 '14 at 18:50
  • 1
    @SabaJamalian: http://grishma102.blogspot.com/2013/12/how-to-make-text-flow-around-images-in.html http://stackoverflow.com/questions/2248759/how-to-layout-text-to-flow-around-an-image – CommonsWare Aug 05 '14 at 19:20