我是 Nativescript 开发的新手,我有一个由 GridLayout 包裹的 ScrollView,在 ScrollView 中我放置了各种 StackLayout,但是滚动布局根本不起作用,其中一个堆栈布局(黄色)显示为居中,知道我的代码有什么问题吗?
<template>
<Page class="background-color:white;">
<ActionBar class="bg_blue_marine">
</ActionBar>
<GridLayout rows="*,auto" columns="*" style="width:100%; height:100%;">
<ScrollView row="0" col="1" orientation="vertical" style="width:100%; height:auto; background-color:rgb(200,200,200);">
<StackLayout style="width:100%; height:400px; background-color:red;"></StackLayout>
<StackLayout style="width:100%; height:400px; background-color:yellow;"></StackLayout>
</ScrollView>
<FlexBoxLayout row="1" col="1" style="width:100%; height:80px; align-items:center; justify-content:space-around; background-color:white;"></FlexBoxLayout>
</GridLayout>
</Page>
</template>
最佳答案
<GridLayout rows="300,*" columns="*">
<ScrollView height="300" orientation="vertical">
<StackLayout orientation="horizontal" horizontalAlignment="center" row="0" col="0" style="background-color:rgb(200,200,200);">
<StackLayout orientation="horizontal" horizontalAlignment="center"
style="width:50%; height:400; background-color:red;"></StackLayout>
<StackLayout orientation="horizontal" horizontalAlignment="left"
style="width:50%; height:400; background-color:yellow;"></StackLayout>
</StackLayout>
</ScrollView>
<FlexBoxLayout row="1" col="0"
style="width:100%; height:80; align-items:center; justify-content:space-around; background-color:white;">
</FlexBoxLayout>
</GridLayout>
将提供以下结果[1]:/image/m4TAG.png
我不确定是否可以将 ScrollView 作为 GridLayout 的一行,您应该使用任何布局。另外,高度和宽度不能使用 px
单位。另外,每当使用 StackLayout 时,请使用“方向”和“对齐”属性。
关于javascript - Nativescript ScrollView 不滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59012473/