由ScrollView

时间:2016-11-21 08:55:42

标签: xml nativescript

我有一个nativescript xml视图,定义如下:

<Page 
 xmlns="http://schemas.nativescript.org/tns.xsd"
 xmlns:menu="components/menu"
 xmlns:header="components/header" 
 loaded="loaded">
<header:header />
<StackLayout orientation="vertical">
<ScrollView>
    <GridLayout rows="auto,auto,auto,auto" cols="auto,auto" >
        <Image      row="0" colSpan="2" src="~/img/tap.png" tap="takePicture"/>
        ...
        <TextField  row="2" col="1" horizontalAlignment="right" />
        <Button     row="3" colSpan="2" text="UPLOAD" />
    </GridLayout>
</ScrollView>
<menu:menu />
</StackLayout>
</Page>

GridLayout太大而无法包含在单个屏幕中,因此我将其包装在ScrollView中。然而,这不起作用:我无法滚动页面,因此,无法访问TextField和Button等最后的UI元素。 我究竟做错了什么?我应该将ScrollView标签插入不同的位置吗?

1 个答案:

答案 0 :(得分:4)

尝试在StackLayout中包装GridLayout。认为问题可能是ScrollView很难计算其滚动高度,因为GridLayout具有&#34; auto&#34; cols和rows。

<ScrollView>
    <StackLayout>
        <GridLayout rows="auto,auto,auto,auto" cols="auto,auto" >
            <Image      row="0" colSpan="2" src="~/img/tap.png" tap="takePicture"/>
            ...
            <TextField  row="2" col="1" horizontalAlignment="right" />
            <Button     row="3" colSpan="2" text="UPLOAD" />
        </GridLayout>
    </StackLayout>
</ScrollView>