The problem
Components (Label and TextField in this case) added to the View are not showed on the screen in some cases.
Test case
To reproduce this issue, run the following example:
var tabGroup = Ti.UI.createTabGroup();
var tab1 = Ti.UI.createTab({
title: 'Tab 1',
window: Ti.UI.createWindow()
});
var tab2 = Ti.UI.createTab({
title: 'Tab 2',
window: Ti.UI.createWindow()
});
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
var scrollView = Ti.UI.createScrollView({
width: '100%',
height: '100%',
layout: 'horizontal',
backgroundColor: '#f00',
contentWidth: 'auto',
contentHeight: 'auto'
});
var view1 = Ti.UI.createView({
width: '50%',
height: 'auto',
layout: 'vertical',
top: 0,
backgroundColor: '#00f'
});
var view2 = Ti.UI.createView({
width: '50%',
top: 0,
height: 'auto',
layout: 'vertical',
backgroundColor: '#0f0'
});
scrollView.add(view1);
scrollView.add(view2);
for (var i = 0; i < 50; ++i) {
var label = Ti.UI.createLabel({
top: 10,
//comment line below to see the components
height: '10%',
text: 'Label ' + i
});
var input = Ti.UI.createTextField({
top: 10,
//comment line below to see the components
height: '10%',
width: 200
});
view1.add(label);
view2.add(input);
}
tab1.window.add(scrollView);
tabGroup.open();
The result
As you should see, two Views in ScrollView have 50% height and components added to them are not visible on the screen.
Expected result
All components should be visible on the screen. If component dimension defined as percentage is commented out, all components are visible on the screen.
In my opinion, components should be able to use percentages for dimension definition. In this particular case, component dimension should be looked up - because View has height defined as "auto" (and ScrollView's contentHeight is set to 'auto'), component size should be determined by the size of the Window (first component higher in the hierarchy that have defined dimension value - that could also be ScrollView because it has height defined as 100%). After that, View should calculate height according to the size of their child components (View have Labels and TextFields).
Tested and Confirmed this issue.
Tested with 2.0.1GA2 on a Samsung Galaxy S2, issue still exists.
The problem reproduce with release 3.0.2 and master release 3.1.0 tested on Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 Titanium SDK version: 3.0.2 Device: Samsung galaxy s duos Android version: 4.0.4 Android Emulator: Android SDK version: 2.2 I think there exist many issues related to the "percentage" unit.