Issue
I've searched around on Google and came across this site where I found a question similar to mine in which how to include a image in a TextView text, for example "hello my name is [image]", and the answer was this:
ImageSpan is = new ImageSpan(context, resId);
text.setSpan(is, index, index + strLength, 0);
I would like to know in this code,
- What am I supposed to type or do in the context?
- Am I supposed to do something to the
text.setSpan()like import or reference or leave it text?
If someone can break this down for me that would be much appreciated.
Solution
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:maxLines="1"
android:text="@string/name"/>
Answered By - Umesh Lakhani Answer Checked By - Marilyn (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.