2
我有一個來自api的對象列表,我在ListView中顯示它。對於列表中的每個項目,我呈現絕對佈局。如果該項目有照片,我將其展示爲完全拉伸,以便它在列表中顯示爲該項目的背景圖像。然後,我正在渲染帶有項目名稱的按鈕,我想要在圖像的中心進行渲染。我瀏覽了文檔,但找不到辦法。本地腳本中絕對佈局中心的位置元素
<ListView [items]="List">
<StackLayout>
<template let-item="item">
<AbsoluteLayout class="list-item">
<Image src="{{item.photo}}" *ngIf="item.photo" stretch="fill"> </Image>
<Button [text]="item.name" (tap)="onItemTap(item)"></Button>
</AbsoluteLayout>
</template>
</StackLayout>
</ListView>
如何計算視圖寬度/高度? – FlavorScape