[TIMOB-3512] Android: vertical layout incorrect order when window opened before adding children
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-05-30T14:50:15.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 2.1.0 |
Components | Android |
Labels | core, module_window, qe-testadded |
Reporter | Paul Dowsett |
Assignee | Neeraj Gupta |
Created | 2011-04-15T03:46:07.000+0000 |
Updated | 2012-07-13T12:22:42.000+0000 |
Description
Tested using Titanium SDK 1.6.1 (15 Mar 2011), Android emulator 2.2
When a window is opened with a vertical layout, and labels (or presumably any view or widget, although this has not been explicitly tested) are added to it, they are displayed in the incorrect order. The following code demonstrates the issue:
var win1 = Ti.UI.createWindow({
title: "Main Window",
exitOnClose: true,
layout: 'vertical',
navBarHidden: false
});
var btnNewWin = Ti.UI.createButton({
top:5,
width:301,
height:57,
title: "New Win"
});
win1.add(btnNewWin);
win1.open();
btnNewWin.addEventListener('click', function() {
var win2 = Ti.UI.createWindow({
title: "Second Window",
layout: 'vertical',
navBarHidden: false
});
win2.open();
for(var i=0; i < 10; i++) {
var lbl = Ti.UI.createLabel({
text: 'Label: ' + i,
textAlign:'left'
});
win2.add(lbl);
}
// win2.open(); // moving open() to here resolves the issue
});
Note that opening the window after the labels have been added works around the issue.
Using the code above, the labels are laid out in the incorrect
order:
http://img845.imageshack.us/img845/2923/screenshot218.png" alt=
"before">
After the workaround is used, labels are correctly
displayed:
http://img703.imageshack.us/img703/1285/screenshot217.png" alt=
"after">
Cannot reproduce with 2.1.0 master builds (05/30/12).
Fixed as part of composite layout enhancements.
Verified fix with Titanium Studio, build: 2.1.0.201206251749 Titanium SDK: 2.1.0.v20120626104306 Device: LG VS910 4G Android version 2.3.6