Probably, this isn't an unknown issue but I wasn't able to find anything helpful in the Q&A's.
I have an ScrollView with contentHeight:'auto' and two child views in it that also have an 'auto' height.
The following example code works fine when building it with Titanium SDK 1.8.0
var win = Titanium.UI.createWindow({backgroundColor:'#fff'}); var scrollView = Ti.UI.createScrollView({ top:0, contentHeight:'auto', contentWidth:320, showVerticalScrollIndicator:true }); var label_one = Ti.UI.createLabel({ text: "Label One", top: 10, height: 'auto' }); scrollView.add(label_one); var label_two = Ti.UI.createLabel({ text: "Label Two", top: label_one.top + label_one.height, height: 'auto' }); scrollView.add(label_two); win.add(scrollView); win.open();With Titanium SDK 2.X.X it doesn't behave the same way. I tried using
height: Ti.UI.SIZE for the labels height properties and contentHeight: Ti.UI.FILL for the ScrollView but it didn't change the layout.
Does anybody know the best way to update the code to work with newest SDK? Thanks
2 Answers
Try using width and height in your scroll view code.
var scrollView = Ti.UI.createScrollView({ top:0, contentHeight:'auto', contentWidth:320, showVerticalScrollIndicator:true });should be used like
var scrollView = Ti.UI.createScrollView({ top:0, height:Ti.UI.FILL, width:320, showVerticalScrollIndicator:true });
OK, I finally found a solution that works for me:
I added the property layout: 'vertical' to the scrollview and set every label to top: 10
Now, the the labels are vertically alinged in the scrollview, no matter how high they are!
Your Answer
This question has been locked and cannot accept new answers.