NativeScript中的GridLayout无法正确显示

时间:2019-06-09 19:01:12

标签: css nativescript

我的问题

我正在尝试使用NativeScript创建此屏幕:

Settings

我正在使用GridLayout,就像每个人都建议的那样。我跟着文档去信(我认为),这是我的结果:

My Outcome

如您所见,甚至没有关闭。这是我的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>


我尝试使用数字,但仍然无法像我需要的那样显示。

我做错了。你能帮我吗?

谢谢。

约翰

1 个答案:

答案 0 :(得分:1)

看看是否有

columns="4*, *, *"

满足您的需求。然后,您可以看到css将填充和居中添加到列中。