首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将ScrollView和网格或Flexview混合使用?

如何将ScrollView和网格或Flexview混合使用?
EN

Stack Overflow用户
提问于 2018-09-02 21:00:15
回答 1查看 130关注 0票数 0

我是新来的本地人。我只是复习了一下教程,并且能够制作出一个具有ScrollView的应用程序的基本代码:​。

代码语言:javascript
复制
<ScrollView (scroll)="onScroll($event)">
    <GridLayout class="m-15" rows="auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto auto">
     <Label class="h3 m-5" height="50" row="0" text="Title 1"></Label>
    <Image class="h3 m-5" row="1" src="https://play.nativescript.org/dist/assets/img/NativeScript_logo.png" height="80" width="80"></Image>
   <Label class="h3 m-5" height="50" row="2" text="Title 3"></Label>
   <Label class="h3 m-5" height="50" row="3" text="Title 4"></Label>
   <Label class="h3 m-5" height="50" row="4" text="Title 5"></Label>
   <Label class="h3 m-5" height="50" row="5" text="Title 6"></Label>
   <Label class="h3 m-5" height="50" row="6" text="Title 7"></Label>
   <Label class="h3 m-5" height="50" row="7" text="Title 8"></Label>
   <Label class="h3 m-5" height="50" row="8" text="Title 9"></Label>
   <Label class="h3 m-5" height="50" row="9" text="Title 10"></Label>
   <Label class="h3 m-5" height="50" row="10" text="Title 10"></Label>
   <Label class="h3 m-5" height="50" row="11" text="Title 11"></Label>
   <Label class="h3 m-5" height="50" row="12" text="Title 12"></Label>
   <Label class="h3 m-5" height="50" row="13" text="Title 13"></Label>
   <Label class="h3 m-5" height="50" row="14" text="Title 14"></Label>
   <Label class="h3 m-5" height="50" row="15" text="Title 15"></Label>
</GridLayout>
</ScrollView>

然而,我想让这些元素位于一个2列的网格中,但是我想不出如何做到这一点而不破坏这个应用程序。有人能帮帮我吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-09-03 06:19:41

在GridLayout中的行中,auto和两列之间缺少逗号,需要添加columns参数,例如使用asterisksnumbersauto

代码语言:javascript
复制
 <GridLayout class="m-15" columns="*,*" rows="auto, auto, auto, auto, auto, auto, auto, auto, auto, auto, auto, auto, auto, auto, auto, auto">

在GridLayout内部的元素中,根据第一列还是第二列,添加col="0"col="1"

代码语言:javascript
复制
<Label class="h3 m-5" height="50" col="0" row="2" text="Title 3"></Label> //third row, first column
<Label class="h3 m-5" height="50" col="1" row="2" text="Title 4"></Label> //third row, second column

关于https://docs.nativescript.org/ui/layouts/layout-containers的更多信息

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52140995

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档