0

I want to replace a string ({img}) e.g "Hello {img} World" with an image.

The image isn't an emoticon and should fill the whole screen width, so the text goes on below the image.

I read about SpannableString/ImageSpan, but would it fit to my problem or is there a better solution to solve this?

The image should be loaded asynchronous using ION-Library, so would it be possible at all, if I use an imagespan?

I would be glad, if anybody would give me a hint or name a layout-element, because I have no idea where to start with.

ForJ9
  • 735
  • 8
  • 24

1 Answers1

1

Please see this solution, basically you can specify an image in your textview xml, then set it programmatically.

Try this ..

  txtview.setCompoundDrawablesWithIntrinsicBounds(
                    R.drawable.image, 0, 0, 0);

Also see this.. http://developer.android.com/reference/android/widget/TextView.html

Try this in xml file

    <TextView
        android:id="@+id/txtStatus"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:drawableLeft="@drawable/image"
        android:drawablePadding="5dp"
        android:singleLine="true"
        android:text="@string/name"/>
Community
  • 1
  • 1
Joel Min
  • 3,387
  • 3
  • 19
  • 38
  • Problem is, that I dont know how much images the API will return, so I need a dynamic solution and I need to load it from a server, so this won't be a solution. – ForJ9 Apr 03 '16 at 01:59