javascript - Nativescript ScrollView 不滚动
问题描述
我对 Nativescript 开发相当陌生,我有一个由 GridLayout 包裹的 ScrollView,在 ScrollView 内我放置了各种 StackLayouts,但是滚动布局根本不起作用,其中一个堆栈布局(黄色)显示为居中,任何想法我的代码有什么问题?
<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]:https ://i.stack.imgur.com/m4TAG.png
我不确定您是否可以将 ScrollView 作为 GridLayout 的一行,您应该使用任何 Layout 来代替。另外,您不能有px
高度和宽度的单位。另外,每当使用 StackLayout 时,请使用 'orientation' 和 'alignment' 属性。
推荐阅读
- java - 如何打印不匹配正则表达式的文件名列表?爪哇 8
- php - 使用 https www 重定向并使用 vhosts、apache2 和 htaccess 进行斜杠
- c++ - 有条件地传递修改后的副本而不是 const original 变得丑陋
- git - 签出到另一个分支时,文件作为未暂存的更改被删除
- sonarqube - Sonarqube 7.9 全新安装,无法登录
- azure - Dynamics 365 API 身份验证 Office 管理密码重置
- java - 如何模拟作为参数传递给方法的异常
- android - android应用第一次加载布局时如何添加提示
- reactjs - 在 Reactstrap 组件上设置 tabIndex
- mallet - Java空指针中的Mallet NaiveBayes分类器