Class SurfaceNode
- Direct Known Subclasses:
SurfaceContainer, SurfaceDynamicText, SurfaceImage, SurfaceProgress, SurfaceSpacer, SurfaceText, SurfaceVector
The base class of all surface layout nodes. A surface descriptor is a small tree of nodes
(columns, rows, boxes, text, images, progress indicators) that every platform can render
natively while the app process is not running -- so a node is pure data: there are no
listeners, no theme lookups and no live Image references in the serialized form.
All nodes share the styling in this class: padding, background color, corner radius, alignment
within the parent, flexible weight, an optional fixed size and an optional action. An action is
a plain string id (plus optional parameters) delivered to the handler registered with
Surfaces.setActionHandler(...) when the user taps the node -- see SurfaceActionEvent.
All dimensions are in display-independent pixels (dips).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the tap action id, or null.Returns the tap action parameters, or null.Returns the alignment within the parent, or null for the platform default.Returns the background color, or null.intReturns the corner radius in dips.intReturns the fixed height in dips, 0 when naturally sized.intReturns the bottom padding in dips.intReturns the left padding in dips.intReturns the right padding in dips.intReturns the top padding in dips.intReturns the flexible-space weight, 0 when naturally sized.intReturns the fixed width in dips, 0 when naturally sized.Assigns a tap action to this node.Assigns a tap action with parameters to this node.setAlignment(SurfaceAlignment alignment) Sets this node's alignment within its parent.setBackground(SurfaceColor color) Sets the background color of this node.setCornerRadius(int radius) Sets the corner radius applied to the node's background.setPadding(int all) Sets the same padding on all four sides.setPadding(int top, int right, int bottom, int left) Sets the padding of each side individually.setSize(int widthDips, int heightDips) Sets a fixed size for this node.setWeight(int weight) Sets the flexible-space weight of this node within a row or column.
-
Constructor Details
-
SurfaceNode
public SurfaceNode()
-
-
Method Details
-
setPadding
Sets the same padding on all four sides.
Parameters
all: padding in dips
Returns
this node, for chaining
-
setPadding
Sets the padding of each side individually.
Parameters
top: top padding in dipsright: right padding in dipsbottom: bottom padding in dipsleft: left padding in dips
Returns
this node, for chaining
-
setBackground
Sets the background color of this node.
Parameters
color: the background color
Returns
this node, for chaining
-
setCornerRadius
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
-
setAlignment
Sets this node's alignment within its parent. In a
SurfaceBoxall nine positions apply; in rows and columns only the cross-axis component is used.Parameters
alignment: the alignment
Returns
this node, for chaining
-
setWeight
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
-
setSize
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 widthheightDips: fixed height in dips, 0 for natural height
Returns
this node, for chaining
-
setAction
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
-
setAction
Assigns a tap action with parameters to this node. The parameter map may contain
String,NumberandBooleanvalues and is delivered verbatim with theSurfaceActionEvent.Parameters
actionId: the app-defined action identifierparams: parameters delivered with the action, may be null
Returns
this node, for chaining
-
getPaddingTop
public int getPaddingTop()Returns the top padding in dips. -
getPaddingRight
public int getPaddingRight()Returns the right padding in dips. -
getPaddingBottom
public int getPaddingBottom()Returns the bottom padding in dips. -
getPaddingLeft
public int getPaddingLeft()Returns the left padding in dips. -
getBackground
Returns the background color, or null. -
getCornerRadius
public int getCornerRadius()Returns the corner radius in dips. -
getAlignment
Returns the alignment within the parent, or null for the platform default. -
getWeight
public int getWeight()Returns the flexible-space weight, 0 when naturally sized. -
getWidthDips
public int getWidthDips()Returns the fixed width in dips, 0 when naturally sized. -
getHeightDips
public int getHeightDips()Returns the fixed height in dips, 0 when naturally sized. -
getActionId
Returns the tap action id, or null. -
getActionParams
-