public class SurfaceBox
- Object
- SurfaceNode
- SurfaceContainer
- SurfaceBox
A container that stacks its children on top of each other. Each child positions itself within
the box via its own
setAlignment(...). Maps to a SwiftUI ZStack, an Android FrameLayout
and a layered box on desktop surfaces.Constructors
public SurfaceBox() |
Methods
public SurfaceBox add(SurfaceNode child) | Adds a child node. |
public SurfaceBox setPadding(int all) | Sets the same padding on all four sides. |
public SurfaceBox setPadding(int top, int right, int bottom, int left) | Sets the padding of each side individually. |
public SurfaceBox setBackground(SurfaceColor color) | Sets the background color of this node. |
public SurfaceBox setCornerRadius(int radius) | Sets the corner radius applied to the node’s background. |
public SurfaceBox setAlignment(SurfaceAlignment alignment) | Sets this node’s alignment within its parent. |
public SurfaceBox setWeight(int weight) | Sets the flexible-space weight of this node within a row or column. |
public SurfaceBox setSize(int widthDips, int heightDips) | Sets a fixed size for this node. |
public SurfaceBox setAction(String actionId) | Assigns a tap action to this node. |
public SurfaceBox setAction(String actionId, Map<String, Object> params) | Assigns a tap action with parameters to this node. |
Inherited methods
Constructor details
SurfaceBox
public SurfaceBox()Method details
add
public SurfaceBox add(SurfaceNode child)Adds a child node.
Parameters
childSurfaceNode- the node to append
Returns
this container, for chaining
setPadding
public SurfaceBox setPadding(int all)Sets the same padding on all four sides.
Parameters
allint- padding in dips
Returns
this node, for chaining
setPadding
public SurfaceBox setPadding(int top, int right, int bottom, int left)Sets the padding of each side individually.
Parameters
topint- top padding in dips
rightint- right padding in dips
bottomint- bottom padding in dips
leftint- left padding in dips
Returns
this node, for chaining
setBackground
public SurfaceBox setBackground(SurfaceColor color)Sets the background color of this node.
Parameters
colorSurfaceColor- the background color
Returns
this node, for chaining
setCornerRadius
public SurfaceBox setCornerRadius(int radius)Sets the corner radius applied to the node’s background. May render square on Android
versions below 12.
Parameters
radiusint- the corner radius in dips
Returns
this node, for chaining
setAlignment
public SurfaceBox setAlignment(SurfaceAlignment alignment)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
alignmentSurfaceAlignment- the alignment
Returns
this node, for chaining
setWeight
public SurfaceBox setWeight(int weight)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
weightint- the relative weight, 0 for natural sizing
Returns
this node, for chaining
setSize
public SurfaceBox setSize(int widthDips, int heightDips)Sets a fixed size for this node. A value of 0 (the default) keeps the natural size of the
respective axis.
Parameters
widthDipsint- fixed width in dips, 0 for natural width
heightDipsint- fixed height in dips, 0 for natural height
Returns
this node, for chaining
setAction
public SurfaceBox setAction(String actionId)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
actionIdString- the app-defined action identifier
Returns
this node, for chaining
setAction
public SurfaceBox setAction(String actionId, Map<String, Object> params)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
actionIdString- the app-defined action identifier
paramsMap<String, Object>- parameters delivered with the action, may be null
Returns
this node, for chaining