StackLayout

Using a StackLayout requires the StackLayout module.

// var StackLayout = require("ui/layouts/stack-layout").StackLayout;

Declaring a StackLayout.

<Page>
  <StackLayout orientation="horizontal">
    <Label text="This is Label 1" />
  </StackLayout>
</Page>

Create StackLayout

var stackLayout = new StackLayout();

Add child view to layout

var btn = new Button();
stackLayout.addChild(btn);

Remove child view from layout

stackLayout.removeChild(btn);

Change layout orientation to Horizontal

<StackLayout orientation="vertical" width="210" height="210" backgroundColor="lightgray">
    <Label text="Label 1" width="50" height="50" backgroundColor="red"></Label>
    <Label text="Label 2" width="50" height="50" backgroundColor="green"></Label>
    <Label text="Label 3" width="50" height="50" backgroundColor="blue"></Label>
    <Label text="Label 4" width="50" height="50" backgroundColor="yellow"></Label>
</StackLayout> 

Stay connected with NativeScript

(expect a newsletter every 4-8 weeks)

NativeScript
NativeScript is licensed under the Apache 2.0 license .
© Progress Software Corporation. All Rights Reserved.