如何在 Titanium 中插入垂直滚动条

How can I insert vertical scrollbar in Titanium

我正在使用 Titanium 构建应用程序

现在我想在一个 Window 中设置一个滚动视图,因为这个 windows 的内容太大了。所以我想插入一个 ScrollView 并显示垂直滚动条。

所以我正在构建这段代码:

<Alloy>
    <Window id="indexWindow" orientation="Titanium.UI.UPSIDE_PORTRAIT"  fullscreen="false">
         <ScrollView id="scrollView" showVerticalScrollIndicator="true"
            showPagingControl= "true" showHorizontalScrollIndicator="true" height="80%" width="80%">

        <View class="container" layout="vertical">
            <!-- title -->
            <Label id="titleDatiAnagrafici" class="labelTitle" ></Label>

            <!-- personal data -->
            <TableView id="form_table" height="Titanium.UI.SIZE">

                <TableViewRow id="name_row" class="row_item" layout="horizontal">
                    <Label id="name_label" class="label" />
                    <Label text="Mario" class="labelData"/>

                    <Label id="surname_label" class="label" left="20px"/>
                    <Label text="Rossi" class="labelData"/>
                </TableViewRow>

                <TableViewRow id="name_row" class="row_item" layout="horizontal">
                    <Label id="address_label" class="label" />
                    <Label text="via Cereate 8, Milano" class="labelData"/>

                </TableViewRow>

                <TableViewRow id="name_row" class="row_item" layout="horizontal">
                    <Label id="phone_label" class="label"/>
                    <Label text="333111222" class="labelData"/>
                </TableViewRow>

            </TableView>



        </View>
        </ScrollView>
    </Window>
</Alloy>

但是我看不到垂直滚动条。

根据文档,您可以在 ScrollView 标签中添加以下属性:

showVerticalScrollIndicator="true"

如果需要,您也可以用同样的方式添加单杠:

showHorizontalScrollIndicator: true

查看文档here

此致

您必须使用视图的高度 属性。

 <Window id="indexWindow" orientation="Titanium.UI.UPSIDE_PORTRAIT"  fullscreen="false">
     <ScrollView id="scrollView" showVerticalScrollIndicator="true"
        showPagingControl= "true" showHorizontalScrollIndicator="true" height="80%" width="80%">

    <View class="container" layout="vertical" height="2000">
        <!-- title -->
        <Label id="titleDatiAnagrafici" class="labelTitle" ></Label>

        <!-- personal data -->
        <TableView id="form_table" height="Titanium.UI.SIZE">

            <TableViewRow id="name_row" class="row_item" layout="horizontal">
                <Label id="name_label" class="label" />
                <Label text="Mario" class="labelData"/>

                <Label id="surname_label" class="label" left="20px"/>
                <Label text="Rossi" class="labelData"/>
            </TableViewRow>

            <TableViewRow id="name_row" class="row_item" layout="horizontal">
                <Label id="address_label" class="label" />
                <Label text="via Cereate 8, Milano" class="labelData"/>

            </TableViewRow>

            <TableViewRow id="name_row" class="row_item" layout="horizontal">
                <Label id="phone_label" class="label"/>
                <Label text="333111222" class="labelData"/>
            </TableViewRow>

        </TableView>



    </View>
    </ScrollView>
</Window>

默认情况下,视图采用其父视图的大小,因此永远不会出现滚动视图。