在ScrollView下插入按钮

时间:2016-08-25 10:49:18

标签: android appcelerator

我正在使用appcelerator构建应用。

现在我构建了这个视图。 这是代码:

<Alloy>
    <ScrollView width="100%" height="80%" 
            showVerticalScrollIndicator="true">
        <View class="container"  width="100%" height="1600">
            <View class="row">
                <Label id="labelRegistry" class="label" width="25%"></Label>
                <Switch id="checkbox" value="true"></Switch>    
            </View>

            <View class="row">
                <Label id="labelNote" class="label" width="25%"></Label>    
                <TextArea hintText="insert note" width="70%" id="textNote"></TextArea>
            </View>

            <View class="row" >
                <Label id="labelPhoneNumber" width="20%" class="label" top="0px"></Label>       
                <Button id="button" onClick="addButton" top="0px"></Button> 

                <TableView id="tableContact" width="75%" height="auto" 
                    onClick="deleteRow">            
                    <TableViewSection id="tableContact" >                
                    </TableViewSection>
                </TableView>

            </View>

            <View class="row" height="auto" width="100%">
                <TableView id="table" class="table" width="100%">
                    <TableViewSection id="table" >

                    </TableViewSection>
                </TableView>
            </View>

        </View>
    </ScrollView>

<View class="container"  width="100%" height="1600">
        <View id="edit_registry_button" onClick="onSave" height="20%" >
            <ImageView id="edit_registry_icon" image="/images/new_icons/edit_icon_white.png" class="button_icon"></ImageView>
            <Label id="edit_registry_label" class="button_label" text="Salva"></Label>
        </View>
    </View>
</Alloy>

正如你所看到的,我有一个高度= 80%的ScrollView,在此之下,我希望用Button获得另一个视图。但是,如果我尝试运行我的应用程序,我只能看到滚动视图。

1 个答案:

答案 0 :(得分:0)

试试此代码

<Alloy>
    <ScrollView width="100%" height="80%" showVerticalScrollIndicator="true" top="0">
        <View class="container" width="100%" height="100%">
            <View class="row">
                <Label id="labelRegistry" class="label" width="25%"></Label>
                <Switch id="checkbox" value="true"></Switch>
            </View>

            <View class="row">
                <Label id="labelNote" class="label" width="25%"></Label>
                <TextArea hintText="insert note" width="70%" id="textNote"></TextArea>
            </View>

            <View class="row">
                <Label id="labelPhoneNumber" width="20%" class="label" top="0px"></Label>
                <Button id="button" onClick="addButton" top="0px"></Button>

                <TableView id="tableContact" width="75%" height="auto" onClick="deleteRow">
                    <TableViewSection id="tableContact"></TableViewSection>
                </TableView>
            </View>

            <View class="row" height="auto" width="100%">
                <TableView id="table" class="table" width="100%">
                    <TableViewSection id="table"></TableViewSection>
                </TableView>
            </View>

        </View>
    </ScrollView>

    <View class="container" width="100%" height="20%" bottom="0">
        <View id="edit_registry_button" onClick="onSave" height="100%">
            <ImageView id="edit_registry_icon" image="/images/new_icons/edit_icon_white.png" class="button_icon"></ImageView>
            <Label id="edit_registry_label" class="button_label" text="Salva"></Label>
        </View>
    </View>
</Alloy>

我已将top:0添加到滚动视图,bottom:0height:20%添加到底部视图。

此外,如果您不需要第一个<View class="container" width="100%" height="100%">样式,则可以将其删除并将Scrollview设置为layout:vertical