Basically, your View 2 should have a top = 0 and bottom=View3.height, but your main problem is that you don't have the exact height of View 3 as it is set to Ti.UI.SIZE.
In order to accomplish this, you'll have to listen for the postlayout event of the View3 and get its exact height through the rect property.
The rect property is a read-only dictionary with the properties x, y,
width and height. It provides the rendered size and position of the
view, and is only available once both it and its ancestors have been
fully drawn.
Here s a working code for both android and iOS:
View XML :
<Alloy>
<Window class="container">
<Button onClick="doClick" top="30">load new text</Button>
<ScrollView id="scrollView" top="100">
<View height="500" backgroundColor="red">
<Label top="0" text="top label"/>
<Label text="middle label"/>
<Label bottom="0" text="bottom label"/>
</View>
</ScrollView>
<View id="containerDynamic" onPostlayout="postlayoutB" height="Ti.UI.SIZE" layout="vertical">
<Label id="label_2" text=""/>
</View>
</Window>
Tss File
".container": {
backgroundColor:"white"
}
"Label": {
width: Ti.UI.SIZE,
height: Ti.UI.SIZE,
color: "#000"
}
"#label": {
font: {
fontSize: 12
}
}
"#containerDynamic": {
bottom: 0,
backgroundColor: "lightgray"
}
"#scrollView": {
top: 0,
backgroundColor: "green",
showScrollbars: true
}
JS File
var lorem = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
function doClick(e) {
var random = getRandomArbitrary(1,lorem.length);
var text = lorem.substring(lorem.length-random, random);
$.label_2.text = text;
}
$.index.open();
function postlayoutB(e){
$.scrollView.bottom = e.source.rect.height
}
function getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;
}
run this code by copying it into a fresh project (index.js, index.xml, index.tss)
understand it and then apply it to your app accordingly
I hope I could have been of some help.