Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Create an Absolute Positioned Layout Using AbsoluteLayout

    2 - 4

    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.



    Become a Member to view code

    You must be a Pro Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    orLog In




    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.