Nativescript 3+;角度2:Listview或绝对版面边距无效
如您所见,我尝试添加属性,如“marginBottom”,但这些都没有效果。我希望列表中的项目之间有更多的空间。我最好怎么做呢Nativescript 3+;角度2:Listview或绝对版面边距无效,listview,nativescript,angular2-nativescript,absolutelayout,Listview,Nativescript,Angular2 Nativescript,Absolutelayout,如您所见,我尝试添加属性,如“marginBottom”,但这些都没有效果。我希望列表中的项目之间有更多的空间。我最好怎么做呢 <ListView [items]="data" class="small-spacing"> <ng-template let-item="item" class="small-spacing" marginBottom="20"> <AbsoluteLayout width="90%" height="110" marg
<ListView [items]="data" class="small-spacing">
<ng-template let-item="item" class="small-spacing" marginBottom="20">
<AbsoluteLayout width="90%" height="110" margin="10" marginBottom="20" backgroundColor="lightblue" class="card" (tap)="navigateToItem(item._id)">
<Image [src]="item.thumbnail" left="10" top="10" width="70" height="90"></Image>
<Label [text]="item.title" left="90" top="10" width="60%" height="20" ></Label>
<Label [text]="item.subtitle" left="90" top="30" width="60%" height="20" textWrap="true" ></Label>
<Label [text]="item.date" left="90" top="50" width="60%" height="70" class="small-text"></Label>
</AbsoluteLayout>
</ng-template>
</ListView>
我找到的解决方案是在
ng模板中使用stackLayout
。然后使用marginBottom
和marginTop
属性将元素正确定位在StackLayout
中
<ListView [items]="data" class="small-spacing">
<ng-template let-item="item" class="small-spacing" style="margin-bottom: 20;">
<StackLayout class="itemTemplateStackLayout" orientation="vertical">
<AbsoluteLayout width="90%" height="110" margin="10" marginBottom="20" marginTop="20" backgroundColor="lightblue" class="card" (tap)="navigateToItem(item._id)">
<Image [src]="item.thumbnail" left="10" top="10" width="70" height="90"></Image>
<Label [text]="item.title" left="90" top="10" width="60%" height="20" ></Label>
<Label [text]="item.subtitle" left="90" top="30" width="60%" height="20" textWrap="true" ></Label>
<Label [text]="item.date" left="90" top="50" width="60%" height="70" class="small-text"></Label>
</AbsoluteLayout>
</StackLayout>
</ng-template>
</ListView>