Class TLabel

java.lang.Object
android.view.View
com.mta.tehreer.widget.TLabel
All Implemented Interfaces:
Drawable.Callback, AccessibilityEventSource, KeyEvent.Callback

public class TLabel extends View
Displays read-only text to the user.
  • Constructor Details

  • Method Details

    • onMeasure

      protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
      Overrides:
      onMeasure in class View
    • onDraw

      protected void onDraw(Canvas canvas)
      Overrides:
      onDraw in class View
    • hitTestPosition

      public int hitTestPosition(float x, float y)
      Performs hit testing. Returns the index of character representing the specified position, or -1 if there is no character at this position.
      Parameters:
      x - The x- coordinate of position.
      y - The y- coordinate of position.
      Returns:
      The index of character representing the specified position, or -1 if there is no character at this position.
    • getGravity

      public int getGravity()
      Returns the horizontal and vertical alignment of this Label.
      Returns:
      The horizontal and vertical alignment of this Label.
    • setGravity

      public void setGravity(int gravity)
      Sets the horizontal alignment of the text and the vertical gravity that will be used when there is extra space in the Label beyond what is required for the text itself.
      Parameters:
      gravity - The horizontal and vertical alignment.
    • getComposedFrame

      public ComposedFrame getComposedFrame()
      Returns the current composed frame that is being displayed.
      Returns:
      The composed frame being displayed.
    • getTypesetter

      public Typesetter getTypesetter()
      Returns the typesetter that is being used to compose text lines.
      Returns:
      The current typesetter.
    • setTypesetter

      public void setTypesetter(Typesetter typesetter)
      Sets the typesetter that should be used to compose text lines. Calling this method will make text and spanned properties null.

      A typesetter is preferred over spanned as it avoids an extra step of creating typesetter from spanned.

      Parameters:
      typesetter - A typesetter object.
      See Also:
    • getSpanned

      public Spanned getSpanned()
      Returns the current spanned that is being displayed. This property will be null if either text or typesetter is being used instead.
      Returns:
      The spanned being displayed.
      See Also:
    • setSpanned

      public void setSpanned(Spanned spanned)
      Sets the spanned that should be displayed. Calling this method will make text property null.

      If performance is required, a typesetter should be used directly.

      Parameters:
      spanned - The spanned to display.
      See Also:
    • getTypeface

      public Typeface getTypeface()
      Returns the current typeface in which the text is being displayed.
      Returns:
      The typeface being used for displaying text.
    • setTypeface

      public void setTypeface(Typeface typeface)
      Sets the typeface in which the text should be displayed.
      Parameters:
      typeface - The typeface to use for displaying text.
    • getText

      public String getText()
      Returns the current text that is being displayed. This property will be null if either spanned or typesetter is being used instead.
      Returns:
      The text being displayed.
      See Also:
    • setText

      public void setText(String text)
      Sets the text that should be displayed. Calling this method will make spanned property null.
      Parameters:
      text - The text to display.
      See Also:
    • getTextSize

      public float getTextSize()
      Returns the current text size (in pixels) in which the text is being displayed.
      Returns:
      The text size to use for displaying text.
    • setTextSize

      public void setTextSize(float textSize)
      Set the text size (in pixels) in which the text should be displayed.
      Parameters:
      textSize - The text size to use for displaying text.
    • getTextColor

      @ColorInt public int getTextColor()
      Returns the current color in which the text is being displayed.
      Returns:
      The color being used for displaying text.
    • setTextColor

      public void setTextColor(@ColorInt int textColor)
      Sets the color in which the text should be displayed.
      Parameters:
      textColor - The color to use for displaying text.
    • getTruncationMode

      public BreakMode getTruncationMode()
      Returns the truncation mode that should be used on the last line of the text in case of overflow.
      Returns:
      The current truncation mode.
    • setTruncationMode

      public void setTruncationMode(BreakMode truncationMode)
      Sets the truncation mode that should be used on the last line of text in case of overflow.
      Parameters:
      truncationMode - A value of BreakMode.
    • getTruncationPlace

      public TruncationPlace getTruncationPlace()
      Returns the truncation place for the last line of the text.
      Returns:
      The current truncation place.
    • setTruncationPlace

      public void setTruncationPlace(TruncationPlace truncationPlace)
      Sets the truncation place for the last line of the text.

      The truncation is disabled if the value of truncationPlace is null.

      Parameters:
      truncationPlace - A value of TruncationPlace.
    • getMaxLines

      public int getMaxLines()
      Returns the maximum number of lines that should be displayed.
      Returns:
      The maximum number of lines that should be displayed.
    • setMaxLines

      public void setMaxLines(int maxLines)
      Makes the Label at most this many lines tall.
      Parameters:
      maxLines - The maximum number of lines that should be displayed.
    • getExtraLineSpacing

      public float getExtraLineSpacing()
      Returns the extra spacing that should be added after each text line. It is resolved before line height multiplier. The default value is zero.
      Returns:
      The current extra line spacing.
      See Also:
    • setExtraLineSpacing

      public void setExtraLineSpacing(float extraLineSpacing)
      Sets the extra spacing that should be added after each text line. It is resolved before line height multiplier. The default value is zero.
      Parameters:
      extraLineSpacing - The extra line spacing in pixels.
      See Also:
    • getLineHeightMultiplier

      public float getLineHeightMultiplier()
      Returns the height multiplier that should be applied on each text line. It is resolved after extra line spacing. The default value is one.
      Returns:
      The current line height multiplier.
      See Also:
    • setLineHeightMultiplier

      public void setLineHeightMultiplier(float lineHeightMultiplier)
      Sets the height multiplier to apply on each text line. It is resolved after extra line spacing. The default value is one.

      The additional spacing is adjusted in such a way that text remains in the middle of the line.

      Parameters:
      lineHeightMultiplier - The multiplication factor.
      See Also:
    • getRenderingStyle

      public RenderingStyle getRenderingStyle()
      Returns the rendering style, used for controlling how text should appear while drawing. The default value is RenderingStyle.FILL.
      Returns:
      The style setting for text.
    • setRenderingStyle

      public void setRenderingStyle(RenderingStyle renderingStyle)
      Sets the rendering style, used for controlling how text should appear while drawing. The default value is RenderingStyle.FILL.
      Parameters:
      renderingStyle - The new style setting for the text.
    • getStrokeColor

      @ColorInt public int getStrokeColor()
      Returns the stroke color for text. The default value is Color.BLACK.
      Returns:
      The stroke color expressed as ARGB integer.
    • setStrokeColor

      public void setStrokeColor(@ColorInt int strokeColor)
      Sets the stroke color text. The default value is Color.BLACK.
      Parameters:
      strokeColor - The 32-bit value of color expressed as ARGB.
    • getStrokeWidth

      @Px public float getStrokeWidth()
      Returns the stroke width for text.
      Returns:
      The stroke width in pixels.
    • setStrokeWidth

      public void setStrokeWidth(@Px float strokeWidth)
      Sets the stroke width for text.
      Parameters:
      strokeWidth - The stroke width in pixels.
    • getStrokeCap

      public StrokeCap getStrokeCap()
      Returns the cap, controlling how the start and end of stroked lines and paths are treated. The default value is StrokeCap.BUTT.
      Returns:
      The stroke cap style for text.
    • setStrokeCap

      public void setStrokeCap(StrokeCap strokeCap)
      Sets the cap, controlling how the start and end of stroked lines and paths are treated. The default value is StrokeCap.BUTT.
      Parameters:
      strokeCap - The new stroke cap style for text.
    • getStrokeJoin

      public StrokeJoin getStrokeJoin()
      Returns the stroke join type for text. The default value is StrokeJoin.ROUND.
      Returns:
      The stroke join type.
    • setStrokeJoin

      public void setStrokeJoin(StrokeJoin strokeJoin)
      Sets the stroke join type for text. The default value is StrokeJoin.ROUND.
      Parameters:
      strokeJoin - The new stroke join type.
    • getStrokeMiter

      @Px public float getStrokeMiter()
      Returns the stroke miter value for text. Used to control the behavior of miter joins when the joins angle is sharp.
      Returns:
      The miter limit in pixels.
    • setStrokeMiter

      public void setStrokeMiter(@Px float strokeMiter)
      Sets thee stroke miter value. This is used to control the behavior of miter joins when the joins angle is sharp.
      Parameters:
      strokeMiter - The value of miter limit in pixels.
    • getShadowRadius

      public float getShadowRadius()
      Returns the radius of the shadow layer.
      Returns:
      The value of shadow radius.
    • setShadowRadius

      public void setShadowRadius(float shadowRadius)
      Sets the radius of the shadow layer. Only works if this Label's layer type is LAYER_TYPE_SOFTWARE.

      The shadow is disabled if the value of shadowRadius is equal to zero.

      Parameters:
      shadowRadius - The value of shadow's radius.
    • getShadowDx

      public float getShadowDx()
      Returns the horizontal offset of the shadow layer.
      Returns:
      The value of shadow's horizontal offset.
    • setShadowDx

      public void setShadowDx(float shadowDx)
      Sets the horizontal offset of the shadow layer.
      Parameters:
      shadowDx - The value of shadow's horizontal offset.
    • getShadowDy

      public float getShadowDy()
      Returns the vertical offset of the shadow layer.
      Returns:
      The value of shadow's vertical offset.
    • setShadowDy

      public void setShadowDy(float shadowDy)
      Sets the vertical offset of the shadow layer.
      Parameters:
      shadowDy - The value of shadow's vertical offset.
    • getShadowColor

      @ColorInt public int getShadowColor()
      Returns the color of the shadow layer.
      Returns:
      The color of the shadow.
    • setShadowColor

      public void setShadowColor(@ColorInt int shadowColor)
      Sets the color of the shadow layer.
      Parameters:
      shadowColor - The color the shadow.