Actually I have TextView with some text. I need to insert an image insight this text. Please suggest the best way to do that. Should be supported on different display sizes.
Asked
Active
Viewed 1,389 times
1
-
possible duplicate http://stackoverflow.com/questions/7913987/how-to-insert-imageview-at-the-end-of-multiline-textview – Vladimir Nov 01 '11 at 10:44
3 Answers
1
Are you talking about to display image inside the TextView at either Top/Bottom/Right/Left side, if yes then:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World, DemoExampleActivity!"
android:drawableLeft="@drawable/icon"
android:drawableRight="@drawable/icon"
android:drawablePadding="10dip"/>
output:

Paresh Mayani
- 127,700
- 71
- 241
- 295
0
You can set the image as the background for the TextView
like this:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Text to be displayed"
android:background ="@drawable/your_image"
/>
Good luck, Arkde

Aurelian Cotuna
- 3,076
- 3
- 29
- 49
0
If want to do it via xml
add this attribute to TextView element
android:background="@drawable/icon"
If at runtime programatically
TextView tv = (TextView)findViewById(R.id.textView);
tv.setBackgroundDrawable(drawable);
or
tv..setBackgroundResource(resid);

Rohit Sharma
- 13,787
- 8
- 57
- 72