Search code examples
androidiosnativescriptnativescript-angular

How to create a custom navigation bar in NativeScript?


I am new to NativeScript and experimenting with it a little via the playground. There are some UIs that i'd like to implement and don't see samples of and I was wondering what would it take to implement? specifically, I'd like to create a bottom navigation such as below, with the middle button.

Bottom Nav


Solution

  • Here is a pseudocode gives you the layout you are looking for.

    <GridLayout>
        <GridLayout rows="*,auto">
            <StackLayout row="0" backgroundColor="#ccc">
                <Label text="Your Content" fontSize="30" textAlignment="center"></Label>
            </StackLayout>
            <GridLayout row="1" columns="*,*" height="48">
                <StackLayout col="0">
                    <Image></Image>
                    <Label text="Groups" textAlignment="center"></Label>
                </StackLayout>
                <StackLayout col="1">
                    <Image></Image>
                    <Label text="Communities" textAlignment="center"></Label>
                </StackLayout>
            </GridLayout>
        </GridLayout>
        <GridLayout borderRadius="50%" width="68" height="68" backgroundColor="#ec5281"
            verticalAlignment="bottom" horizontalAlignment="center" marginBottom="20">
            <Label text="Post" color="white" verticalAlignment="center"
                horizontalAlignment="center"></Label>
        </GridLayout>
    </GridLayout>
    

    Lear more about NativeScript layouts at https://www.nslayouts.com/ You can also find sample projects at Marketplace