Class ReplacementSpan

All Implemented Interfaces:
UpdateAppearance, UpdateLayout
Direct Known Subclasses:
DynamicDrawableSpan

public abstract class ReplacementSpan extends MetricAffectingSpan
  • Constructor Details

    • ReplacementSpan

      public ReplacementSpan()
  • Method Details

    • updateMeasureState

      public final void updateMeasureState(@Nonnull TextPaint paint)
      This method does nothing, since ReplacementSpans are measured explicitly instead of affecting Paint properties.
      Specified by:
      updateMeasureState in class MetricAffectingSpan
      Parameters:
      paint - the paint used for measuring the text
    • getSize

      public abstract int getSize(@Nonnull TextPaint paint, CharSequence text, int start, int end, @Nullable FontMetricsInt fm)
      Returns the width of the span. Extending classes can set the height of the span by updating attributes of FontMetricsInt. If the span covers the whole text, and the height is not set, draw(Canvas, CharSequence, int, int, float, int, int, int, TextPaint) will not be called for the span.
      Parameters:
      paint - Paint instance.
      text - Current text.
      start - Start character index for span.
      end - End character index for span.
      fm - Font metrics, can be null.
      Returns:
      Width of the span.
    • draw

      public abstract void draw(@Nonnull Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, @Nonnull TextPaint paint)
      Draws the span into the canvas.
      Parameters:
      canvas - Canvas into which the span should be rendered.
      text - Current text.
      start - Start character index for span.
      end - End character index for span.
      x - Edge of the replacement closest to the leading margin.
      top - Top of the line.
      y - Baseline.
      bottom - Bottom of the line.
      paint - Paint instance.