This lesson is for PRO members.

Unlock this lesson NOW!
Already subscribed? sign in

Create an Absolute Positioned Layout Using AbsoluteLayout

1:31 JavaScript lesson by

We will use the AbsoluteLayout component to create a layout container which uses left-top coordinates to position its child components in a NativeScript app.

Get the Code Now
click to level up

egghead.io comment guidelines

Avatar
egghead.io

We will use the AbsoluteLayout component to create a layout container which uses left-top coordinates to position its child components in a NativeScript app.

Start by adding an absolute layout to your page. Inside of the absolute layout, we'll add a few view components. First, we'll add a button with the text set to hello. We need to set the left and top coordinates, so we'll use left set to 10 and top set to 100.

We'll add another button with the text set to goodbye and the left position set to 140 and the top position to 250. Last, let's add a label with the text of Egghead and the left value set to 60 and the top set to 400. When we run this, these view components will be positioned absolute by their top left coordinates.

Here they are. The hello button is positioned 10 from the left and 100 from the top of the view. The goodbye button is positioned 140 from the left and 250 from the top. Last, your Egghead label is 60 from the left and 400 from the top of the page.

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?