Anand Savjani Anand Savjani - 1 year ago 149
Android Question

Add ImageView after text

enter image description here

I want to achieve this functionality . Please provide suggestion for it.

Answer Source

Try this, this adds a drawable in a TextView after text.

TextView text=(TextView)findViewById(;
SpannableStringBuilder builder = new SpannableStringBuilder();
builder.append("This is text with image!").append(" ");
Drawable myIcon = getResources().getDrawable(R.drawable.ic_new);
myIcon.setBounds(0, 0, test.getLineHeight(),test.getLineHeight());
builder.setSpan(new ImageSpan(myIcon, ImageSpan.ALIGN_BASELINE),builder.length() - 1, builder.length(), 0);