# Class SurfaceText

java.lang.Object
com.codename1.surfaces.SurfaceNode
com.codename1.surfaces.SurfaceText

public class SurfaceText extends SurfaceNode

A static text node. The text may embed `${key}` placeholders that the platform renderer substitutes from the state map of the current timeline entry or live-activity update, so frequently changing values do not require re-publishing the whole descriptor:

    new SurfaceText("${status}").setFontSize(13).setColor(SurfaceColor.SECONDARY_LABEL)

For values the OS should animate on its own clock (countdowns, elapsed time) use `SurfaceDynamicText` instead.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SurfaceText(String text)`
  Creates a text node.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `SurfaceColor`
  `getColor()`
  Returns the text color, or null for the platform default.
  `int`
  `getFontSize()`
  Returns the font size in dips, 0 for the platform default.
  `SurfaceFontWeight`
  `getFontWeight()`
  Returns the font weight, or null for the platform default.
  `int`
  `getMaxLines()`
  Returns the maximum line count, 0 for unlimited.
  `String`
  `getText()`
  Returns the text, potentially containing `${key}` placeholders.
  `SurfaceText`
  `setAction(String actionId)`
  Assigns a tap action to this node.
  `SurfaceText`
  `setAction(String actionId, Map<String,Object> params)`
  Assigns a tap action with parameters to this node.
  `SurfaceText`
  `setAlignment(SurfaceAlignment alignment)`
  Sets this node's alignment within its parent.
  `SurfaceText`
  `setBackground(SurfaceColor background)`
  Sets the background color of this node.
  `SurfaceText`
  `setColor(SurfaceColor color)`
  Sets the text color.
  `SurfaceText`
  `setCornerRadius(int radius)`
  Sets the corner radius applied to the node's background.
  `SurfaceText`
  `setFontSize(int fontSize)`
  Sets the font size.
  `SurfaceText`
  `setFontWeight(SurfaceFontWeight fontWeight)`
  Sets the font weight.
  `SurfaceText`
  `setMaxLines(int maxLines)`
  Limits the number of rendered lines.
  `SurfaceText`
  `setPadding(int all)`
  Sets the same padding on all four sides.
  `SurfaceText`
  `setPadding(int top, int right, int bottom, int left)`
  Sets the padding of each side individually.
  `SurfaceText`
  `setSize(int widthDips, int heightDips)`
  Sets a fixed size for this node.
  `SurfaceText`
  `setWeight(int weight)`
  Sets the flexible-space weight of this node within a row or column.

  ### Methods inherited from class SurfaceNode

  `getActionId, getActionParams, getAlignment, getBackground, getCornerRadius, getHeightDips, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getWeight, getWidthDips`

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### SurfaceText

    public SurfaceText(String text)

    Creates a text node.

    ###### Parameters

    - `text`: literal text, optionally embedding `${key}` state placeholders

- ## Method Details

  - ### setFontSize

    public SurfaceText setFontSize(int fontSize)

    Sets the font size.

    ###### Parameters

    - `fontSize`: the size in dips

    ###### Returns

    this text node, for chaining

  - ### setFontWeight

    public SurfaceText setFontWeight(SurfaceFontWeight fontWeight)

    Sets the font weight.

    ###### Parameters

    - `fontWeight`: the weight

    ###### Returns

    this text node, for chaining

  - ### setColor

    public SurfaceText setColor(SurfaceColor color)

    Sets the text color.

    ###### Parameters

    - `color`: the color

    ###### Returns

    this text node, for chaining

  - ### setMaxLines

    public SurfaceText setMaxLines(int maxLines)

    Limits the number of rendered lines.

    ###### Parameters

    - `maxLines`: maximum line count, 0 for unlimited

    ###### Returns

    this text node, for chaining

  - ### getText

    public String getText()
    Returns the text, potentially containing `${key}` placeholders.

  - ### getFontSize

    public int getFontSize()
    Returns the font size in dips, 0 for the platform default.

  - ### getFontWeight

    public SurfaceFontWeight getFontWeight()
    Returns the font weight, or null for the platform default.

  - ### getColor

    public SurfaceColor getColor()
    Returns the text color, or null for the platform default.

  - ### getMaxLines

    public int getMaxLines()
    Returns the maximum line count, 0 for unlimited.

  - ### setPadding

    public SurfaceText setPadding(int all)
    Description copied from class: `SurfaceNode`

    Sets the same padding on all four sides.

    ###### Parameters

    - `all`: padding in dips

    ###### Returns

    this node, for chaining

    Overrides:
      `setPadding` in class `SurfaceNode`

  - ### setPadding

    public SurfaceText setPadding(int top, int right, int bottom, int left)
    Description copied from class: `SurfaceNode`

    Sets the padding of each side individually.

    ###### Parameters

    - `top`: top padding in dips
    - `right`: right padding in dips
    - `bottom`: bottom padding in dips
    - `left`: left padding in dips

    ###### Returns

    this node, for chaining

    Overrides:
      `setPadding` in class `SurfaceNode`

  - ### setBackground

    public SurfaceText setBackground(SurfaceColor background)
    Description copied from class: `SurfaceNode`

    Sets the background color of this node.

    ###### Parameters

    - `color`: the background color

    ###### Returns

    this node, for chaining

    Overrides:
      `setBackground` in class `SurfaceNode`

  - ### setCornerRadius

    public SurfaceText setCornerRadius(int radius)
    Description copied from class: `SurfaceNode`

    Sets the corner radius applied to the node's background. May render square on Android versions below 12.

    ###### Parameters

    - `radius`: the corner radius in dips

    ###### Returns

    this node, for chaining

    Overrides:
      `setCornerRadius` in class `SurfaceNode`

  - ### setAlignment

    public SurfaceText setAlignment(SurfaceAlignment alignment)
    Description copied from class: `SurfaceNode`

    Sets this node's alignment within its parent. In a `SurfaceBox` all nine positions apply; in rows and columns only the cross-axis component is used.

    ###### Parameters

    - `alignment`: the alignment

    ###### Returns

    this node, for chaining

    Overrides:
      `setAlignment` in class `SurfaceNode`

  - ### setWeight

    public SurfaceText setWeight(int weight)
    Description copied from class: `SurfaceNode`

    Sets the flexible-space weight of this node within a row or column. Nodes with a weight share the leftover space of the parent proportionally; a weight of 0 (the default) sizes the node to its natural size.

    ###### Parameters

    - `weight`: the relative weight, 0 for natural sizing

    ###### Returns

    this node, for chaining

    Overrides:
      `setWeight` in class `SurfaceNode`

  - ### setSize

    public SurfaceText setSize(int widthDips, int heightDips)
    Description copied from class: `SurfaceNode`

    Sets a fixed size for this node. A value of 0 (the default) keeps the natural size of the respective axis.

    ###### Parameters

    - `widthDips`: fixed width in dips, 0 for natural width
    - `heightDips`: fixed height in dips, 0 for natural height

    ###### Returns

    this node, for chaining

    Overrides:
      `setSize` in class `SurfaceNode`

  - ### setAction

    public SurfaceText setAction(String actionId)
    Description copied from class: `SurfaceNode`

    Assigns a tap action to this node. Tapping the node opens (or foregrounds) the app and delivers the action id to the handler registered with `Surfaces.setActionHandler(...)`. Note that small iOS home-screen widgets only honor the action of the root node.

    ###### Parameters

    - `actionId`: the app-defined action identifier

    ###### Returns

    this node, for chaining

    Overrides:
      `setAction` in class `SurfaceNode`

  - ### setAction

    public SurfaceText setAction(String actionId, Map<String,Object> params)
    Description copied from class: `SurfaceNode`

    Assigns a tap action with parameters to this node. The parameter map may contain `String`, `Number` and `Boolean` values and is delivered verbatim with the `SurfaceActionEvent`.

    ###### Parameters

    - `actionId`: the app-defined action identifier
    - `params`: parameters delivered with the action, may be null

    ###### Returns

    this node, for chaining

    Overrides:
      `setAction` in class `SurfaceNode`