Nativescript 为什么Listview不能在nativescrit angular2的scrollview中滚动

Nativescript 为什么Listview不能在nativescrit angular2的scrollview中滚动,nativescript,Nativescript,#我在Scrollview中使用listview,但listview在Scrollview中不能作为顶级父视图滚动 component.html <ScrollView> <StackLayout class="zindex"> <!--<AutoComplete [items]="ArrayVillage" (itemTap)="itemTapped($event)"> </AutoComplete>-->

#我在Scrollview中使用listview,但listview在Scrollview中不能作为顶级父视图滚动

component.html
    <ScrollView>
  <StackLayout class="zindex">
        <!--<AutoComplete [items]="ArrayVillage" (itemTap)="itemTapped($event)"> </AutoComplete>-->
        <SearchBar row="0" #sb hint="Search for a country and press enter" (clear)="onClear()" [text]="searchPhrase" (submit)="onSubmit(sb.text)"></SearchBar>
        <ListView row="1" [items]="myItems" class="list-group">
          <template let-item="item">
            <GridLayout class="item" class="list-group-item">
              <Label [text]="item.name" class="list-group-item-heading"></Label>
            </GridLayout>
          </template>
        </ListView>
      </StackLayout>
 <ScrollView>
component.html

尝试将滚动视图包装到绝对布局中

<AbsoluteLayout>
    <ScrollView>
        <StackLayout class="zindex">
         //Rest of stuff
        </StackLayout>
        <ScrollView>
</AbsoluteLayout>

//其他的东西

将滚动视图放在另一个视图中不是一个好做法。它不起作用,因为scrollview试图计算无限视图,并使用可滚动的内部视图进行计算。在某些情况下,控制父视图可能会起作用,但不要这样做

在您的代码中,我有一个问题,为什么要滚动搜索栏?试试这个结构,我想这就是你想要的

<StackLayout>
<SearchBar></SearchBar>
<ListView>
    <template>
        <GridLayout >
            <Label ></Label>
        </GridLayout>
    </template>
</ListView>

看看,玩模拟器,你会看到在Begging时它似乎可以工作,但当你使用单击尝试滚动时,它是“计算机鼠标滚动”,它不再工作了,因为屏幕不知道哪个可滚动元素必须滚动

完成2个可滚动部分可以是一个解决方案,如视频结尾所示(我使用Javascript在Nativescript中实现,因为我在一个项目中工作,但基本相同)


尝试使用Repeater而不是中提到的ListView。下面是一个示例,说明如何在ScrollView中包含Repeater,并获得可滚动的整个布局

<ScrollView>
    <StackLayout class="margin">
        <Label text="{{ description }}"></Label>
        <Repeater items="{{ options }}" row="1">
            <Repeater.itemTemplate>
                <StackLayout>
                    <Label text="{{ description }}"></Label>
                </StackLayout>
            </Repeater.itemTemplate>
        </Repeater>
    </StackLayout>
</ScrollView>


如果这是整个布局,则不需要滚动视图,除非您希望搜索栏移动。默认情况下,ListView会滚动。也许你所追求的最终结果与我想象的不同,但如果你只是希望列表滚动删除scrollview我在scrollview中有许多组件不仅listview我在scrollview中为listview提供了固定大小,但是listview不可滚动检查更新的答案,我希望它能帮助你,否则,发送您想要在视图中获得的内容,以便我们能够管理解决方案来实现它。我有一个作为scrollview的父视图,我有许多组件,如textview和drpodown list等,我还有一个listview,如果我使用scrollbar作为父视图,它就不会滚动。这是一个边界。您应该扩展您的答案,在此处包含尽可能多的信息,并使用该链接仅供参考。
<ScrollView>
    <StackLayout class="margin">
        <Label text="{{ description }}"></Label>
        <Repeater items="{{ options }}" row="1">
            <Repeater.itemTemplate>
                <StackLayout>
                    <Label text="{{ description }}"></Label>
                </StackLayout>
            </Repeater.itemTemplate>
        </Repeater>
    </StackLayout>
</ScrollView>