2016-08-25 90 views
0

我正在用appcelerator构建一个应用程序。在ScrollView下插入按钮

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

<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%滚动型,这下,我想有按钮另一种观点。但是,如果我尝试运行我的应用程序,我只能看到滚动视图。

+0

是什么'高度= 1600'这个? –

+0

应该将按钮的容器视图放到另一个'Scrollview'或其他'layout'中吗? –

回答

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%">的造型,你可以删除这一点,并设置了滚动到layout:vertical