Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Inherited Constants](https://developer.android.com/reference/android/text/style/ImageSpan#inhconstants) \| [Inherited Fields](https://developer.android.com/reference/android/text/style/ImageSpan#inhfields) \| [Ctors](https://developer.android.com/reference/android/text/style/ImageSpan#pubctors) \| [Methods](https://developer.android.com/reference/android/text/style/ImageSpan#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/text/style/ImageSpan#inhmethods)

# ImageSpan

*** ** * ** ***


`
public


class
ImageSpan
`


`


`

`


`

`


`

`


`

`

extends https://developer.android.com/reference/android/text/style/DynamicDrawableSpan


`

`


`

|---|---|---|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||||||
| ↳ | [android.text.style.CharacterStyle](https://developer.android.com/reference/android/text/style/CharacterStyle) |||||
|   | ↳ | [android.text.style.MetricAffectingSpan](https://developer.android.com/reference/android/text/style/MetricAffectingSpan) ||||
|   |   | ↳ | [android.text.style.ReplacementSpan](https://developer.android.com/reference/android/text/style/ReplacementSpan) |||
|   |   |   | ↳ | [android.text.style.DynamicDrawableSpan](https://developer.android.com/reference/android/text/style/DynamicDrawableSpan) ||
|   |   |   |   | ↳ | android.text.style.ImageSpan |

<br />

*** ** * ** ***

Span that replaces the text it's attached to with a `https://developer.android.com/reference/android/graphics/drawable/Drawable` that can be aligned with
the bottom or with the baseline of the surrounding text. The drawable can be constructed from
varied sources:

- `https://developer.android.com/reference/android/graphics/Bitmap` - see `https://developer.android.com/reference/android/text/style/ImageSpan#ImageSpan(android.content.Context,%20android.graphics.Bitmap)` and `https://developer.android.com/reference/android/text/style/ImageSpan#ImageSpan(android.content.Context,%20android.graphics.Bitmap,%20int)`
- `https://developer.android.com/reference/android/graphics/drawable/Drawable` - see `https://developer.android.com/reference/android/text/style/ImageSpan#ImageSpan(android.graphics.drawable.Drawable,%20int)`
- resource id - see `https://developer.android.com/reference/android/text/style/ImageSpan#ImageSpan(android.content.Context,%20int,%20int)`
- `https://developer.android.com/reference/android/net/Uri` - see `https://developer.android.com/reference/android/text/style/ImageSpan#ImageSpan(android.content.Context,%20android.net.Uri,%20int)`

The default value for the vertical alignment is `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BOTTOM`


For example, an `ImagedSpan` can be used like this:

```
SpannableString string = new SpannableString("Bottom: span.\nBaseline: span.");
// using the default alignment: ALIGN_BOTTOM
string.setSpan(new ImageSpan(this, R.mipmap.ic_launcher), 7, 8, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
string.setSpan(new ImageSpan(this, R.mipmap.ic_launcher, DynamicDrawableSpan.ALIGN_BASELINE),
22, 23, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
```
![](https://developer.android.com/static/reference/android/images/text/style/imagespan.png) Text with `ImageSpan`s aligned bottom and baseline.

<br />

## Summary

| ### Inherited constants |
|---|
| From class `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan` |---|---| | `int` | `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BASELINE` A constant indicating that the bottom of this span should be aligned with the baseline of the surrounding text. | | `int` | `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BOTTOM` 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. | | `int` | `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_CENTER` A constant indicating that this span should be vertically centered between the top and the lowest descender. | |

| ### Inherited fields |
|---|
| From class `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan` |---|---| | ` protected final int` | `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#mVerticalAlignment` | |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/text/style/ImageSpan#ImageSpan(android.content.Context,%20android.graphics.Bitmap)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/graphics/Bitmap bitmap) ` Constructs an `https://developer.android.com/reference/android/text/style/ImageSpan` from a `https://developer.android.com/reference/android/content/Context` and a `https://developer.android.com/reference/android/graphics/Bitmap` with the default alignment `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BOTTOM` |
| ` https://developer.android.com/reference/android/text/style/ImageSpan#ImageSpan(android.content.Context,%20android.graphics.Bitmap,%20int)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/graphics/Bitmap bitmap, int verticalAlignment) ` Constructs an `https://developer.android.com/reference/android/text/style/ImageSpan` from a `https://developer.android.com/reference/android/content/Context`, a `https://developer.android.com/reference/android/graphics/Bitmap` and a vertical alignment. |
| ` https://developer.android.com/reference/android/text/style/ImageSpan#ImageSpan(android.content.Context,%20android.net.Uri)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/net/Uri uri) ` Constructs an `https://developer.android.com/reference/android/text/style/ImageSpan` from a `https://developer.android.com/reference/android/content/Context` and a `https://developer.android.com/reference/android/net/Uri` with the default alignment `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BOTTOM`. |
| ` https://developer.android.com/reference/android/text/style/ImageSpan#ImageSpan(android.content.Context,%20android.net.Uri,%20int)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/net/Uri uri, int verticalAlignment) ` Constructs an `https://developer.android.com/reference/android/text/style/ImageSpan` from a `https://developer.android.com/reference/android/content/Context`, a `https://developer.android.com/reference/android/net/Uri` and a vertical alignment. |
| ` https://developer.android.com/reference/android/text/style/ImageSpan#ImageSpan(android.content.Context,%20int)(https://developer.android.com/reference/android/content/Context context, int resourceId) ` Constructs an `https://developer.android.com/reference/android/text/style/ImageSpan` from a `https://developer.android.com/reference/android/content/Context` and a resource id with the default alignment `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BOTTOM` |
| ` https://developer.android.com/reference/android/text/style/ImageSpan#ImageSpan(android.content.Context,%20int,%20int)(https://developer.android.com/reference/android/content/Context context, int resourceId, int verticalAlignment) ` Constructs an `https://developer.android.com/reference/android/text/style/ImageSpan` from a `https://developer.android.com/reference/android/content/Context`, a resource id and a vertical alignment. |
| ` https://developer.android.com/reference/android/text/style/ImageSpan#ImageSpan(android.graphics.Bitmap)(https://developer.android.com/reference/android/graphics/Bitmap b) ` *This constructor is deprecated. Use `https://developer.android.com/reference/android/text/style/ImageSpan#ImageSpan(android.content.Context,%20android.graphics.Bitmap)` instead.* |
| ` https://developer.android.com/reference/android/text/style/ImageSpan#ImageSpan(android.graphics.Bitmap,%20int)(https://developer.android.com/reference/android/graphics/Bitmap b, int verticalAlignment) ` *This constructor is deprecated. Use `https://developer.android.com/reference/android/text/style/ImageSpan#ImageSpan(android.content.Context,%20android.graphics.Bitmap,%20int)` instead.* |
| ` https://developer.android.com/reference/android/text/style/ImageSpan#ImageSpan(android.graphics.drawable.Drawable)(https://developer.android.com/reference/android/graphics/drawable/Drawable drawable) ` Constructs an `https://developer.android.com/reference/android/text/style/ImageSpan` from a drawable with the default alignment `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BOTTOM`. |
| ` https://developer.android.com/reference/android/text/style/ImageSpan#ImageSpan(android.graphics.drawable.Drawable,%20int)(https://developer.android.com/reference/android/graphics/drawable/Drawable drawable, int verticalAlignment) ` Constructs an `https://developer.android.com/reference/android/text/style/ImageSpan` from a drawable and a vertical alignment. |
| ` https://developer.android.com/reference/android/text/style/ImageSpan#ImageSpan(android.graphics.drawable.Drawable,%20java.lang.String)(https://developer.android.com/reference/android/graphics/drawable/Drawable drawable, https://developer.android.com/reference/java/lang/String source) ` Constructs an `https://developer.android.com/reference/android/text/style/ImageSpan` from a drawable and a source with the default alignment `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BOTTOM` |
| ` https://developer.android.com/reference/android/text/style/ImageSpan#ImageSpan(android.graphics.drawable.Drawable,%20java.lang.String,%20int)(https://developer.android.com/reference/android/graphics/drawable/Drawable drawable, https://developer.android.com/reference/java/lang/String source, int verticalAlignment) ` Constructs an `https://developer.android.com/reference/android/text/style/ImageSpan` from a drawable, a source and a vertical alignment. |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/graphics/drawable/Drawable` | ` https://developer.android.com/reference/android/text/style/ImageSpan#getDrawable()() ` Your subclass must implement this method to provide the bitmap to be drawn. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/text/style/ImageSpan#getSource()() ` Returns the source string that was saved during construction. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/text/style/ImageSpan#toString()() ` Returns a string representation of the object. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/android/text/style/DynamicDrawableSpan ` |---|---| | ` void` | ` https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#draw(android.graphics.Canvas,%20java.lang.CharSequence,%20int,%20int,%20float,%20int,%20int,%20int,%20android.graphics.Paint)(https://developer.android.com/reference/android/graphics/Canvas canvas, https://developer.android.com/reference/java/lang/CharSequence text, int start, int end, float x, int top, int y, int bottom, https://developer.android.com/reference/android/graphics/Paint paint) ` Draws the span into the canvas. | | ` abstract https://developer.android.com/reference/android/graphics/drawable/Drawable` | ` https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#getDrawable()() ` Your subclass must implement this method to provide the bitmap to be drawn. | | ` int` | ` https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#getSize(android.graphics.Paint,%20java.lang.CharSequence,%20int,%20int,%20android.graphics.Paint.FontMetricsInt)(https://developer.android.com/reference/android/graphics/Paint paint, https://developer.android.com/reference/java/lang/CharSequence text, int start, int end, https://developer.android.com/reference/android/graphics/Paint.FontMetricsInt fm) ` Returns the width of the span. | | ` int` | ` https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#getVerticalAlignment()() ` Returns the vertical alignment of this span, one of `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BOTTOM`, `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BASELINE` or `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_CENTER`. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#toString()() ` Returns a string representation of the object. | ||
| From class ` https://developer.android.com/reference/android/text/style/ReplacementSpan ` |---|---| | ` abstract void` | ` https://developer.android.com/reference/android/text/style/ReplacementSpan#draw(android.graphics.Canvas,%20java.lang.CharSequence,%20int,%20int,%20float,%20int,%20int,%20int,%20android.graphics.Paint)(https://developer.android.com/reference/android/graphics/Canvas canvas, https://developer.android.com/reference/java/lang/CharSequence text, int start, int end, float x, int top, int y, int bottom, https://developer.android.com/reference/android/graphics/Paint paint) ` Draws the span into the canvas. | | ` https://developer.android.com/reference/java/lang/CharSequence` | ` https://developer.android.com/reference/android/text/style/ReplacementSpan#getContentDescription()() ` Gets a brief description of this ReplacementSpan for use in accessibility support. | | ` abstract int` | ` https://developer.android.com/reference/android/text/style/ReplacementSpan#getSize(android.graphics.Paint,%20java.lang.CharSequence,%20int,%20int,%20android.graphics.Paint.FontMetricsInt)(https://developer.android.com/reference/android/graphics/Paint paint, https://developer.android.com/reference/java/lang/CharSequence text, int start, int end, https://developer.android.com/reference/android/graphics/Paint.FontMetricsInt fm) ` Returns the width of the span. | | ` void` | ` https://developer.android.com/reference/android/text/style/ReplacementSpan#setContentDescription(java.lang.CharSequence)(https://developer.android.com/reference/java/lang/CharSequence contentDescription) ` Sets the specific content description into ReplacementSpan. | | ` void` | ` https://developer.android.com/reference/android/text/style/ReplacementSpan#updateDrawState(android.text.TextPaint)(https://developer.android.com/reference/android/text/TextPaint ds) ` This method does nothing, since ReplacementSpans are drawn explicitly instead of affecting Paint properties. | | ` void` | ` https://developer.android.com/reference/android/text/style/ReplacementSpan#updateMeasureState(android.text.TextPaint)(https://developer.android.com/reference/android/text/TextPaint p) ` This method does nothing, since ReplacementSpans are measured explicitly instead of affecting Paint properties. | ||
| From class ` https://developer.android.com/reference/android/text/style/MetricAffectingSpan ` |---|---| | ` https://developer.android.com/reference/android/text/style/MetricAffectingSpan` | ` https://developer.android.com/reference/android/text/style/MetricAffectingSpan#getUnderlying()() ` Returns "this" for most MetricAffectingSpans, but for MetricAffectingSpans that were generated by `https://developer.android.com/reference/android/text/style/CharacterStyle#wrap(android.text.style.CharacterStyle)`, returns the underlying MetricAffectingSpan. | | ` abstract void` | ` https://developer.android.com/reference/android/text/style/MetricAffectingSpan#updateMeasureState(android.text.TextPaint)(https://developer.android.com/reference/android/text/TextPaint textPaint) ` Classes that extend MetricAffectingSpan implement this method to update the text formatting in a way that can change the width or height of characters. | ||
| From class ` https://developer.android.com/reference/android/text/style/CharacterStyle ` |---|---| | ` https://developer.android.com/reference/android/text/style/CharacterStyle` | ` https://developer.android.com/reference/android/text/style/CharacterStyle#getUnderlying()() ` Returns "this" for most CharacterStyles, but for CharacterStyles that were generated by `https://developer.android.com/reference/android/text/style/CharacterStyle#wrap(android.text.style.CharacterStyle)`, returns the underlying CharacterStyle. | | ` abstract void` | ` https://developer.android.com/reference/android/text/style/CharacterStyle#updateDrawState(android.text.TextPaint)(https://developer.android.com/reference/android/text/TextPaint tp) ` | | ` static https://developer.android.com/reference/android/text/style/CharacterStyle` | ` https://developer.android.com/reference/android/text/style/CharacterStyle#wrap(android.text.style.CharacterStyle)(https://developer.android.com/reference/android/text/style/CharacterStyle cs) ` A given CharacterStyle can only applied to a single region of a given Spanned. | ||
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public constructors

### ImageSpan

Added in [API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ImageSpan (Context context, 
                Bitmap bitmap)
```

Constructs an `https://developer.android.com/reference/android/text/style/ImageSpan` from a `https://developer.android.com/reference/android/content/Context` and a `https://developer.android.com/reference/android/graphics/Bitmap` with the default
alignment `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BOTTOM`

<br />

| Parameters ||
|---|---|
| `context` | `Context`: context used to create a drawable from `bitmap` based on the display metrics of the resources. This value cannot be `null`. <br /> |
| `bitmap` | `Bitmap`: bitmap to be rendered. This value cannot be `null`. <br /> |

### ImageSpan

Added in [API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ImageSpan (Context context, 
                Bitmap bitmap, 
                int verticalAlignment)
```

Constructs an `https://developer.android.com/reference/android/text/style/ImageSpan` from a `https://developer.android.com/reference/android/content/Context`, a `https://developer.android.com/reference/android/graphics/Bitmap` and a vertical
alignment.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: context used to create a drawable from `bitmap` based on the display metrics of the resources. This value cannot be `null`. <br /> |
| `bitmap` | `Bitmap`: bitmap to be rendered. This value cannot be `null`. <br /> |
| `verticalAlignment` | `int`: one of `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BOTTOM` or `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BASELINE` <br /> |

### ImageSpan

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ImageSpan (Context context, 
                Uri uri)
```

Constructs an `https://developer.android.com/reference/android/text/style/ImageSpan` from a `https://developer.android.com/reference/android/content/Context` and a `https://developer.android.com/reference/android/net/Uri` with the default
alignment `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BOTTOM`. The Uri source can be retrieved via
`https://developer.android.com/reference/android/text/style/ImageSpan#getSource()`

<br />

| Parameters ||
|---|---|
| `context` | `Context`: context used to create a drawable from `bitmap` based on the display metrics of the resources. This value cannot be `null`. <br /> |
| `uri` | `Uri`: `https://developer.android.com/reference/android/net/Uri` used to construct the drawable that will be rendered. This value cannot be `null`. <br /> |

### ImageSpan

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ImageSpan (Context context, 
                Uri uri, 
                int verticalAlignment)
```

Constructs an `https://developer.android.com/reference/android/text/style/ImageSpan` from a `https://developer.android.com/reference/android/content/Context`, a `https://developer.android.com/reference/android/net/Uri` and a vertical
alignment. The Uri source can be retrieved via `https://developer.android.com/reference/android/text/style/ImageSpan#getSource()`

<br />

| Parameters ||
|---|---|
| `context` | `Context`: context used to create a drawable from `bitmap` based on the display metrics of the resources. This value cannot be `null`. <br /> |
| `uri` | `Uri`: `https://developer.android.com/reference/android/net/Uri` used to construct the drawable that will be rendered. This value cannot be `null`. <br /> |
| `verticalAlignment` | `int`: one of `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BOTTOM` or `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BASELINE` <br /> |

### ImageSpan

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ImageSpan (Context context, 
                int resourceId)
```

Constructs an `https://developer.android.com/reference/android/text/style/ImageSpan` from a `https://developer.android.com/reference/android/content/Context` and a resource id with the default
alignment `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BOTTOM`

<br />

| Parameters ||
|---|---|
| `context` | `Context`: context used to retrieve the drawable from resources. This value cannot be `null`. <br /> |
| `resourceId` | `int`: drawable resource id based on which the drawable is retrieved <br /> |

### ImageSpan

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ImageSpan (Context context, 
                int resourceId, 
                int verticalAlignment)
```

Constructs an `https://developer.android.com/reference/android/text/style/ImageSpan` from a `https://developer.android.com/reference/android/content/Context`, a resource id and a vertical
alignment.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: context used to retrieve the drawable from resources. This value cannot be `null`. <br /> |
| `resourceId` | `int`: drawable resource id based on which the drawable is retrieved. <br /> |
| `verticalAlignment` | `int`: one of `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BOTTOM` or `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BASELINE` <br /> |

### ImageSpan

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ImageSpan (Bitmap b)
```


**This constructor is deprecated.**   

Use `https://developer.android.com/reference/android/text/style/ImageSpan#ImageSpan(android.content.Context,%20android.graphics.Bitmap)` instead.

<br />

<br />

| Parameters ||
|---|---|
| `b` | `Bitmap`: This value cannot be `null`. <br /> |

### ImageSpan

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ImageSpan (Bitmap b, 
                int verticalAlignment)
```


**This constructor is deprecated.**   

Use `https://developer.android.com/reference/android/text/style/ImageSpan#ImageSpan(android.content.Context,%20android.graphics.Bitmap,%20int)` instead.

<br />

<br />

| Parameters ||
|---|---|
| `b` | `Bitmap`: This value cannot be `null`. <br /> |
| `verticalAlignment` | `int` <br /> |

### ImageSpan

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ImageSpan (Drawable drawable)
```

Constructs an `https://developer.android.com/reference/android/text/style/ImageSpan` from a drawable with the default
alignment `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BOTTOM`.

<br />

| Parameters ||
|---|---|
| `drawable` | `Drawable`: drawable to be rendered. This value cannot be `null`. <br /> |

### ImageSpan

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ImageSpan (Drawable drawable, 
                int verticalAlignment)
```

Constructs an `https://developer.android.com/reference/android/text/style/ImageSpan` from a drawable and a vertical alignment.

<br />

| Parameters ||
|---|---|
| `drawable` | `Drawable`: drawable to be rendered. This value cannot be `null`. <br /> |
| `verticalAlignment` | `int`: one of `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BOTTOM` or `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BASELINE` <br /> |

### ImageSpan

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ImageSpan (Drawable drawable, 
                String source)
```

Constructs an `https://developer.android.com/reference/android/text/style/ImageSpan` from a drawable and a source with the default
alignment `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BOTTOM`

<br />

| Parameters ||
|---|---|
| `drawable` | `Drawable`: drawable to be rendered. This value cannot be `null`. <br /> |
| `source` | `String`: drawable's Uri source. This value cannot be `null`. <br /> |

### ImageSpan

Added in [API level 3](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public ImageSpan (Drawable drawable, 
                String source, 
                int verticalAlignment)
```

Constructs an `https://developer.android.com/reference/android/text/style/ImageSpan` from a drawable, a source and a vertical alignment.

<br />

| Parameters ||
|---|---|
| `drawable` | `Drawable`: drawable to be rendered. This value cannot be `null`. <br /> |
| `source` | `String`: drawable's uri source. This value cannot be `null`. <br /> |
| `verticalAlignment` | `int`: one of `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BOTTOM` or `https://developer.android.com/reference/android/text/style/DynamicDrawableSpan#ALIGN_BASELINE` <br /> |

## Public methods

### getDrawable

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Drawable getDrawable ()
```

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.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/graphics/drawable/Drawable` | <br /> |

### getSource

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getSource ()
```

Returns the source string that was saved during construction.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the source string that was saved during construction. This value may be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/text/style/ImageSpan#ImageSpan(android.graphics.drawable.Drawable,%20java.lang.String)`
- `https://developer.android.com/reference/android/text/style/ImageSpan#ImageSpan(android.content.Context,%20android.net.Uri)`

### toString

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

Returns a string representation of the object.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of the object. <br /> |