It seems that in order to add an ImageSpan to a Spannable in Android, I have to actually replace some text with the Image. For example:
Spannable span = new SpannableString("Foo imageplace Bar!");
Drawable android = context.getResources().getDrawable(R.drawable.android);
android.setBounds(0, 0, 32,32);
ImageSpan image = new ImageSpan(android, ImageSpan.ALIGN_BASELINE);
span.setSpan(image, 4, 14, Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
This will replace "imageplace" with the image. Because I'm dealing with complex multi-span text and reiteration, it's a bit of a headache to insert meaningless text at each place I want the android icon. But it looks like if start and end of span are the same, the image won't be included. Is there any way around this?
If you want to insert Drawable at the end of the text, Drawable is hiding the last character of the text to avoid that add another character at the end of the text and start the drawable at that character.