简体   繁体   English

nativescript创建类似于布局的砌体

[英]nativescript create masonry like layout

I want to make a layout just like a masonry layout, which item automatically arranged to next row if the screen width is not enough. 我想像砌体布局一样进行布局,如果屏幕宽度不足,该项目会自动排列到下一行。 but without using gridlayout. 但不使用gridlayout。 these both layout are not working. 这两个布局均不起作用。

using stacklayout : 使用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>

using Gridlayout 使用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>

您可以使用垂直方向的环绕布局来实现此布局。

There's (currently) no out of the box way to create a masonry layout. (当前)没有开箱即用的方式来创建砖石布局。 However, as you've full access to the platform API:s, this is something you can implement yourself. 但是,由于您拥有对平台API:s的完全访问权限,因此您可以自己实现这一点。

The easiest way would be to use the Telerik UI component ListView . 最简单的方法是使用Telerik UI组件ListView But please note that this is a payed component (this is the way Telerik makes money). 但是请注意,这是付费组件(这是Telerik赚钱的方式)。 There's, a free trial you can test with. 有一个免费试用版,您可以试用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM