I set Image Drawable as a SpannableString in a TextView, but the image comes out larger than the text, which looks weird. I need to reduce the size of the image so that it has the same height as the text:
Here is what I tried:
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); SpannableStringBuilder builder = new SpannableStringBuilder(holder.temptext.getText()); builder.setSpan(new ImageSpan(drawable), selectionCursor - ":)".length(), selectionCursor, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); holder.temptext.setText(builder); holder.temptext.setSelection(selectionCursor); holder.caption.setText(builder);
source share