Using a StackLayout requires the StackLayout module.

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

Declaring a StackLayout.

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

Create StackLayout

var stackLayout = new StackLayout();

Add child view to layout

var btn = new Button();

Remove child view from layout


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>
Is this article helpful? Yes / No
Thank you for your feedback!

Tell us how we can improve this article

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