John S.
John S.

Reputation: 514

GridLayout in NativeScript not displaying properly

My Problem

I am trying to create this screen in NativeScript:

Settings

I am using a GridLayout like everyone has recommended. I followed the docs to the letter ( I think ) and this is my outcome:

My Outcome

As you see, not even close. Here is my XML:

<Page
    navigatingTo="onNavigatingTo"  
    xmlns="http://schemas.nativescript.org/tns.xsd">

    <ActionBar class="action-bar customActionBar">
        <!-- 
        Use the NavigationButton as a side-drawer button in Android
        because ActionItems are shown on the right side of the ActionBar
        -->
        <NavigationButton ios:visibility="collapsed" icon="res://menu" tap="onDrawerButtonTap"></NavigationButton>
        <!-- 
        Use the ActionItem for IOS with position set to left. Using the
        NavigationButton as a side-drawer button in iOS is not possible,
        because its function is to always navigate back in the application.
        -->
        <ActionItem icon="res://navigation/menu" 
            android:visibility="collapsed" 
            tap="onDrawerButtonTap"
            ios.position="left">
        </ActionItem>
        <Label class="action-bar-title" text="Settings"></Label>
    </ActionBar>

    <GridLayout columns="2*, auto, auto" rows="75, auto, auto" width="100%" height="100%" backgroundColor="lightgray" >
    <Label text="Notifications" row="0" col="0"/>
    <Label text="Push" row="0" col="1" />
    <Label text="Email" row="0" col="2" />
<Label text="Messages" row="1" col="0"/>
<Switch checked="true" (checkedChange)="onCheckedChange($event)" class="m-15" row="1" col="1"></Switch>
 <Switch checked="true" (checkedChange)="onCheckedChange($event)" class="m-15" row="1" col="2"></Switch>
  </GridLayout>
</Page>


I tried playing around with the numbers, and it still won't display like I need it to.

I am doing something wrong. Can you help me?

Thank you.

John

Upvotes: 0

Views: 710

Answers (1)

David
David

Reputation: 598

See if something like

columns="4*, *, *"

yields what you want. You can then see css to add padding and centering to the columns.

Upvotes: 1

Related Questions