![](/img/trans.png)
[英]Masonry (Pinterest) style layout without absolute position (like Google+)
[英]nativescript create masonry like layout
我想像砌體布局一樣進行布局,如果屏幕寬度不足,該項目會自動排列到下一行。 但不使用gridlayout。 這兩個布局均不起作用。
使用stacklayout:
<StackLayout orientation="horizontal" style="vertical-align:top;">
<Button text="one" style="height:50;"/>
<Button text="two" style="height:50;"/>
<Button text="three" style="height:50;"/>
<Button text="four" style="height:50;"/>
<Button text="five" style="height:50;"/>
<Button text="five" style="height:50;"/>
<Button text="five" style="height:50;"/>
<Button text="five" style="height:50;"/>
</StackLayout>
使用Gridlayout
<GridLayout rows="174,174,auto" columns="147,147" horizontalAlignment="center" verticalAlignment="center">
<Image col="0" row="0" cssClass="imglogo" src="~/images/icondapur.png" stretch="aspectFit" horizontalAlignment="center"/>
<Image col="0" row="1" cssClass="imglogo" src="~/images/iconrokok.png" stretch="aspectFit" horizontalAlignment="center"/>
<Image col="1" row="0" cssClass="imglogo" src="~/images/iconsabun.png" stretch="aspectFit" horizontalAlignment="center"/>
<Image col="1" row="1" cssClass="imglogo" src="~/images/iconsnack.png" stretch="aspectFit" horizontalAlignment="center"/>
</GridLayout>
您可以使用垂直方向的環繞布局來實現此布局。
(當前)沒有開箱即用的方式來創建磚石布局。 但是,由於您擁有對平台API:s的完全訪問權限,因此您可以自己實現這一點。
最簡單的方法是使用Telerik UI組件ListView 。 但是請注意,這是付費組件(這是Telerik賺錢的方式)。 有一個免費試用版,您可以試用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.