我正在用Titanium构建应用程序

现在,我想在一个窗口中设置一个滚动视图,因为该窗口的内容对于设备来说很大。所以我想插入一个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>


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

最佳答案

您必须使用视图的height属性。

 <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>


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

10-05 20:30
查看更多