【问题标题】:nativescript create masonry like layoutnativescript 创建类似砌体的布局
【发布时间】:2015-12-02 23:03:40
【问题描述】:

我想做一个像砌体布局一样的布局,如果屏幕宽度不够,哪个项目会自动排列到下一行。但不使用网格布局。这两种布局都不起作用。

使用堆栈布局:

 <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 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>

【问题讨论】:

    标签: javascript android nativescript


    【解决方案1】:

    您可以使用带有垂直方向的Wrap Layout 来实现此布局。

    【讨论】:

      【解决方案2】:

      (目前)没有开箱即用的方式来创建砌体布局。但是,由于您可以完全访问平台 API:s,因此您可以自己实现。

      最简单的方法是使用Telerik UI component ListView。但请注意,这是一个付费组件(这是 Telerik 赚钱的方式)。有,您可以免费试用。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-03-20
        • 2019-11-11
        • 1970-01-01
        • 2021-12-22
        相关资源
        最近更新 更多