Class RelativeSizeSpan

All Implemented Interfaces:
ParcelableSpan, UpdateAppearance, UpdateLayout, Parcelable

public class RelativeSizeSpan extends MetricAffectingSpan implements ParcelableSpan
Uniformly scales the size of the text to which it's attached by a certain proportion.

For example, a RelativeSizeSpan that increases the text size by 50% can be constructed like this:


 SpannableString string = new SpannableString("Text with relative size span");
 string.setSpan(new RelativeSizeSpan(1.5f), 10, 24, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
  • Constructor Details

    • RelativeSizeSpan

      public RelativeSizeSpan(float proportion)
      Creates a RelativeSizeSpan based on a proportion.
      Parameters:
      proportion - the proportion with which the text is scaled.
    • RelativeSizeSpan

      public RelativeSizeSpan(@NonNull Parcel src)
      Creates a RelativeSizeSpan from a parcel.
  • Method Details

    • getSpanTypeId

      public int getSpanTypeId()
      Description copied from interface: ParcelableSpan
      Return a special type identifier for this span class.
      Specified by:
      getSpanTypeId in interface ParcelableSpan
    • writeToParcel

      public void writeToParcel(@NonNull Parcel dest, int flags)
      Description copied from interface: Parcelable
      The subclass implements the method to flatten its contents by calling the methods of Parcel for its primitive values.
      Specified by:
      writeToParcel in interface Parcelable
      Parameters:
      dest - the parcel to write the object's data to
      flags - the flags about how the object should be written
    • getSizeChange

      public float getSizeChange()
      Returns:
      the proportion with which the text size is changed.
    • updateMeasureState

      public void updateMeasureState(@NonNull TextPaint paint)
      Description copied from class: MetricAffectingSpan
      Classes that extend MetricAffectingSpan implement this method to update the text formatting in a way that can change the width or height of characters.
      Specified by:
      updateMeasureState in class MetricAffectingSpan
      Parameters:
      paint - the paint used for measuring the text