Package icyllis.modernui.text.style

# Class ImageSpan

java.lang.Object
icyllis.modernui.text.style.CharacterStyle
icyllis.modernui.text.style.MetricAffectingSpan
icyllis.modernui.text.style.ReplacementSpan
icyllis.modernui.text.style.DynamicDrawableSpan
icyllis.modernui.text.style.ImageSpan

All Implemented Interfaces:
  `UpdateAppearance`, `UpdateLayout`

public class ImageSpan extends DynamicDrawableSpan
Span that replaces the text it's attached to with a `Drawable` that can be aligned with the bottom or with the baseline of the surrounding text. The drawable can be constructed from varied sources:

- `Image` - see `ImageSpan(Image)` and `ImageSpan(Image, int)`
- `Drawable` - see `ImageSpan(Drawable, int)`

The default value for the vertical alignment is `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);

Text with `ImageSpan`s aligned bottom and baseline.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class icyllis.modernui.text.style.DynamicDrawableSpan

  `DynamicDrawableSpan.AlignmentType`

- ## Field Summary

  ### Fields inherited from class icyllis.modernui.text.style.DynamicDrawableSpan

  `ALIGN_BASELINE, ALIGN_BOTTOM, ALIGN_CENTER, mVerticalAlignment`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ImageSpan(Context context, Image image)`
  Constructs an `ImageSpan` from a `Context` and an `Image` with the default alignment `DynamicDrawableSpan.ALIGN_BOTTOM`
  `ImageSpan(Context context, Image image, int verticalAlignment)`
  Constructs an `ImageSpan` from a `Context`, an `Image` and a vertical alignment.
  `ImageSpan(Drawable drawable)`
  Constructs an `ImageSpan` from a drawable with the default alignment `DynamicDrawableSpan.ALIGN_BOTTOM`.
  `ImageSpan(Drawable drawable, int verticalAlignment)`
  Constructs an `ImageSpan` from a drawable and a vertical alignment.
  `ImageSpan(Image image)`
  Deprecated.
  `ImageSpan(Image image, int verticalAlignment)`
  Deprecated.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Drawable`
  `getDrawable()`
  Your subclass must implement this method to provide the bitmap to be drawn.

  ### Methods inherited from class icyllis.modernui.text.style.DynamicDrawableSpan

  `draw, getSize, getVerticalAlignment`

  ### Methods inherited from class icyllis.modernui.text.style.ReplacementSpan

  `updateMeasureState`

  ### Methods inherited from class icyllis.modernui.text.style.MetricAffectingSpan

  `getUnderlying, updateDrawState`

  ### Methods inherited from class icyllis.modernui.text.style.CharacterStyle

  `wrap`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ImageSpan

    @Deprecated public ImageSpan(@NonNull Image image)
    Deprecated.
    Constructs an `ImageSpan` from an `Image` with the default alignment `DynamicDrawableSpan.ALIGN_BOTTOM`
    Parameters:
      `image` - image to be rendered

  - ### ImageSpan

    @Deprecated public ImageSpan(@NonNull Image image, int verticalAlignment)
    Deprecated.
    Constructs an `ImageSpan` from an `Image` and a vertical alignment.
    Parameters:
      `image` - image to be rendered
      `verticalAlignment` - one of `DynamicDrawableSpan.ALIGN_BOTTOM` or `DynamicDrawableSpan.ALIGN_BASELINE`

  - ### ImageSpan

    public ImageSpan(@NonNull Context context, @NonNull Image image)
    Constructs an `ImageSpan` from a `Context` and an `Image` with the default alignment `DynamicDrawableSpan.ALIGN_BOTTOM`
    Parameters:
      `context` - context used to create a drawable from based on the display metrics of the resources
      `image` - image to be rendered

  - ### ImageSpan

    public ImageSpan(@NonNull Context context, @NonNull Image image, int verticalAlignment)
    Constructs an `ImageSpan` from a `Context`, an `Image` and a vertical alignment.
    Parameters:
      `context` - context used to create a drawable from image based on the display metrics of the resources
      `image` - image to be rendered
      `verticalAlignment` - one of `DynamicDrawableSpan.ALIGN_BOTTOM` or `DynamicDrawableSpan.ALIGN_BASELINE`

  - ### ImageSpan

    public ImageSpan(@NonNull Drawable drawable)
    Constructs an `ImageSpan` from a drawable with the default alignment `DynamicDrawableSpan.ALIGN_BOTTOM`.
    Parameters:
      `drawable` - drawable to be rendered

  - ### ImageSpan

    public ImageSpan(@NonNull Drawable drawable, int verticalAlignment)
    Constructs an `ImageSpan` from a drawable and a vertical alignment.
    Parameters:
      `drawable` - drawable to be rendered
      `verticalAlignment` - one of `DynamicDrawableSpan.ALIGN_BOTTOM` or `DynamicDrawableSpan.ALIGN_BASELINE`

- ## Method Details

  - ### getDrawable

    @NonNull public Drawable getDrawable()
    Description copied from class: `DynamicDrawableSpan`
    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.
    Specified by:
      `getDrawable` in class `DynamicDrawableSpan`