Class “Stack”

Object > NativeObject > Widget > Composite > Stack

A composite with the layout property initialized with a Stack. All children are automatically arranged in one vertical stack, starting from the top. The layoutData on the children is ignored.

Type: Stack extends Composite
Constructor: public
Singleton: No
Namespace: tabris
Direct subclasses: None
JSX Support: Element: <Stack/>
Parent Elements: <Canvas/>, <Composite/>, <Page/>, <RefreshComposite/>, <ScrollView/>, <Stack/>, <Tab/>
Child Elements: Any standalone widget element
Text Content: Not supported

Examples

JavaScript

import {Stack, contentView, TextView} from 'tabris';

const stack = new Stack({
  layoutData: 'stretch',
  spacing: 16
}).appendTo(contentView);

stack.append(
  new TextView({text: 'top'}),
  new TextView({text: 'center'}),
  new TextView({text: 'bottom'})
);

See also:

JSX Creating a simple Stack
JSX Creating a Stack with horizontal alignment
JSX Creating a Stack with vertical alignment

Constructor

new Stack(properties?)

Parameter Type Description
properties Properties<Stack> Sets all key-value pairs in the properties object as widget properties. Optional.

Properties

alignment

Determines the horizontal placement of the children. For the stretchX value to work correctly the Stack needs to be given a width either by setting width or by setting left and right.

Type: 'left'
| 'centerX'
| 'stretchX'
| 'right'
Default: 'left'
Settable: By Constructor or JSX
Change Event: Not supported

This property can only be set via constructor or JSX. Once set, it cannot change anymore.

See also:

JSX stack-alignment.jsx

layout

The stack layout manager responsible for interpreting the layoutData of the child widgets of this Composite.

Type: StackLayout
Default: StackLayout
Settable: By Constructor or JSX
Change Event: Not supported

This property can only be set via constructor or JSX. Once set, it cannot change anymore.

spacing

Additional space to add between the children in device independent pixel.

Type: number
Default: 16
Settable: By Constructor or JSX
Change Event: Not supported

This property can only be set via constructor or JSX. Once set, it cannot change anymore.