/**@class android.text.style.DynamicDrawableSpan @extends android.text.style.ReplacementSpan Span that replaces the text it's attached to with a {@link Drawable} that can be aligned with the bottom or with the baseline of the surrounding text. <p> For an implementation that constructs the drawable from various sources (<code>Bitmap</code>, <code>Drawable</code>, resource id or <code>Uri</code>) use {@link android.text.style.ImageSpan}. <p> A simple implementation of <code>DynamicDrawableSpan</code> that uses drawables from resources looks like this: <pre> class MyDynamicDrawableSpan extends DynamicDrawableSpan { private final Context mContext; private final int mResourceId; public MyDynamicDrawableSpan(Context context, @DrawableRes int resourceId) { mContext = context; mResourceId = resourceId; } {@literal @}Override public Drawable getDrawable() { Drawable drawable = mContext.getDrawable(mResourceId); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); return drawable; } }</pre> The class can be used like this: <pre> SpannableString string = new SpannableString("Text with a drawable span"); string.setSpan(new MyDynamicDrawableSpan(context, R.mipmap.ic_launcher), 12, 20, Spanned .SPAN_EXCLUSIVE_EXCLUSIVE);</pre> <img src="{@docRoot}reference/android/images/text/style/dynamicdrawablespan.png" /> <figcaption>Replacing text with a drawable.</figcaption> */ var DynamicDrawableSpan = { /** A constant indicating that the bottom of this span should be aligned with the bottom of the surrounding text, i.e., at the same level as the lowest descender in the text. */ ALIGN_BOTTOM : "0", /** A constant indicating that the bottom of this span should be aligned with the baseline of the surrounding text. */ ALIGN_BASELINE : "1", /** A constant indicating that this span should be vertically centered between the top and the lowest descender. */ ALIGN_CENTER : "2", /**Returns the vertical alignment of this span, one of {@link #ALIGN_BOTTOM}, {@link #ALIGN_BASELINE} or {@link #ALIGN_CENTER}. */ getVerticalAlignment : function( ) {}, /**Your subclass must implement this method to provide the bitmap to be drawn. The dimensions of the bitmap must be the same from each call to the next. */ getDrawable : function( ) {}, /** */ getSize : function( ) {}, /** */ draw : function( ) {}, };