在NativeScript中使用GridLayout

时间:2015-07-11 11:55:45

标签: nativescript

我正在努力学习NativeScript。在这个过程中,我想我会创建一些常见的屏幕。第一个是登录屏幕。在这方面,我创建了以下xml。

Login.xml

<Page xmlns="http://www.nativescript.org/tns.xsd" loaded="pageLoaded">
  <GridLayout columns="*, *", rows="80, 80, 80, 80, auto">
    <Label text="Username" row="0" col="0" />
    <TextField row="1" col="0"  />

    <Label text="Password" row="2"  col="0" />
    <TextField row="3" col="0" />
  </GridLayout>
</Page>

当我运行此应用程序时,所有4个控件(Label,TextField,Label,TextField)都位于屏幕中间的另一个顶部。我不明白为什么。我只想尝试使用基本的GridLayout

2 个答案:

答案 0 :(得分:0)

在第二行,您在列和行声明之间有一个错误的逗号。在XML中,属性用空格分隔。

<GridLayout columns="*, *", rows="80, 80, 80, 80, auto">

应该是

<GridLayout columns="*, *" rows="80, 80, 80, 80, auto">

答案 1 :(得分:0)

尽管有额外的逗号,你也可以删除columns属性,因为你将all设置为col = 0,它默认设置为0