钛中 Alloy 元素的余量 属性

margin property for Alloy element in Titanium

我有一个 Alloy 列表视图中行的项目模板,如下所示。我想将 3 个标签垂直排列成一行,并且 margin-top 5dp 彼此。我怎样才能为 Android 和 iOS 做到这一点?

<Templates>
   <ItemTemplate name="row" height="100dp">
         <Label bindId="name"/>
         <Label bindId="weight"/>
         <Label bindId="distance"/>
   </ItemTemplate>
</Templates>

在你的 xml 文件中,像这样调整它

<Templates>
   <ItemTemplate id="templateRow" name="row" height="100dp">
         <Label id="name" bindId="name"/>
         <Label id=weight" bindId="weight"/>
         <Label id="distance" bindId="distance"/>
   </ItemTemplate>
</Templates>

在你的 tss 文件中:

"#templateRow":{
     layout: "vertical"
},
"#name":{
    top: '5dp',
},
"#weight":{
    top: '5dp'
},
"#distance":{
    top: '5dp'
}

或者:

<Templates>
   <ItemTemplate layout="vertical" name="row" height="100dp">
         <Label bindId="name" top="5dp"/>
         <Label bindId="weight" top="5dp"/>
         <Label bindId="distance" top="5dp"/>
   </ItemTemplate>
</Templates>