DrawableMarginSpan

图片+Margin样式。

DrawableMarginSpan(Drawable drawable):参数drawable,用于显示的图片。

DrawableMarginSpan(Drawable drawable, int margin):参数drawable,用于显示的图片,参数margin,图片和文字的距离。

示例:

Drawable drawable = getResources().getDrawable(R.drawable.ic_launcher);
DrawableMarginSpan drawableMarginSpan = new DrawableMarginSpan(drawable);
//DrawableMarginSpan drawableMarginSpan = new DrawableMarginSpan(drawable, 20);

String text = "打开百度";
SpannableString spannableString = new SpannableString(text);
spannableString.setSpan(drawableMarginSpan, 2, text.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);

TextView textView = (TextView) findViewById(R.id.text_view);
textView.setText(spannableString);