Appcelerator 更改 ScrollView 上的内容高度

Appcelerator change Content height on a ScrollView

我的 alloy 项目中有一个滚动视图,我需要在按下按钮时添加一些视图,但是内容高度、可滚动区域没有改变,底部内容消失了从视图。 这是我的 Alloy 查看 (.xml) 文件

<Alloy>
  <Window class="container">
    <ScrollView id="MainView" >
      <View id="innerContent" class="rowLayout">
        <Label>Address 1</Label>
        <TextField id="Address1" class="textArea"></TextField> 
      </View>
    </ScrollView>
    <View id="buttonView">
      <Button id="button" onClick="doClick" title="Add New Address Input" top="10" width="100" height="50" />
    </View>
  </Window>
</Alloy>

我的样式文件 (.tss),包含所有样式:

    ".container": {
        backgroundColor:"white",
        height: Titanium.UI.FILL
    }
    "#MainView": { 
        width: Titanium.UI.FILL,
        height: Titanium.UI.FILL,
        scrollType: "vertical",
        layout: "vertical",
        bottom: "100dp",
        top: "20dp",
        borderColor: "#008000",
        borderWidth: "1px",
        left:"2dp",
        right: "2dp"

    }

    "#buttonView" : {
        height: "50dp",
        width: Titanium.UI.FILL,
        right: "10dp",
        left: "10dp",
        bottom: '8dp',
        borderColor: "#000000",
        borderWidth: "1px"
    }
    ".rowLayout": {
        layout: "vertical"
    }
    ".textArea" : {
        height: "70dp",
        width: Titanium.UI.FILL,
        borderColor: "#000000",
        borderWidth: "1dp",
        left: "8dp",
        right: "8dp"
    }

还有我的控制器 (.js)

var counter=0;
function doClick() { 
  counter++;

  var label = Ti.UI.createLabel({
    text: "Address " + counter + " :"
  });
  var textField = Ti.UI.createTextField({
    height: "70dp",
    width: Titanium.UI.FILL,
    borderColor: "#000000",
    borderWidth: "1dp",
    top: "5dp",
    right: "8dp",
    left: "8dp"
  });

  $.innerContent.add(label);
  $.innerContent.add(textField);
}

$.index.open();

The scroll views does not scroll, or if I already set 3 or four inputs it scroll only to the point where the fourth input was

首先要做的是将您的样式从 .xml 移动到 .tss 以增加概览

尝试将 ScrollView 高度设置为 Ti.UI.SIZE,然后将 layout 设置为 vertical,然后在 click 函数中添加新视图在 top: '5%', bottom: '5%'

但请记住...您的 ScrollView 外面有一个按钮,当您 ScrollView 增加高度时,它会离开屏幕