Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3512] Android: vertical layout incorrect order when window opened before adding children

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2012-05-30T14:50:15.000+0000
Affected Version/sn/a
Fix Version/sRelease 2.1.0
ComponentsAndroid
Labelscore, module_window, qe-testadded
ReporterPaul Dowsett
AssigneeNeeraj Gupta
Created2011-04-15T03:46:07.000+0000
Updated2012-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">

Comments

  1. Max Stepanov 2012-05-30

    Cannot reproduce with 2.1.0 master builds (05/30/12).
  2. Neeraj Gupta 2012-05-30

    Fixed as part of composite layout enhancements.
  3. Olga Romero 2012-06-26

    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

JSON Source