Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Issues with vertical-layout and width/height

Hello everyone,
i have some problems width the width- / height-attributes on a layout: 'vertical' window on iphone. I'm using Titanium SDK 1.4.1.1.

if i use the following code:

var win = Titanium.UI.createWindow({  
    backgroundColor:'yellow',
    layout: 'vertical'
});

var tableData = [
    {title: "Test1"},
    {title: "Test2"},
    {title: "Test3"}
];

var table = Titanium.UI.createTableView({
    data: tableData,
    backgroundColor: 'blue',
    width: 200,
    height: "100%"
});
    win.add(table);

win.open();

the TableView doesn't appear in the window, an height: 'auto' property does also not work.

if i remove the vertical-layout property from the window and add an height: "100%" property to the TableView, it will work:

var win = Titanium.UI.createWindow({  
    backgroundColor:'yellow'
});

var tableData = [
    {title: "Test1"},
    {title: "Test2"},
    {title: "Test3"}
];

var table = Titanium.UI.createTableView({
    data: tableData,
    backgroundColor: 'blue',
    width: 200,
    height: "100%"
});
    win.add(table);

win.open();

but a height: "auto" property does not work. if i remove the complete height-attribute from the TableView, the TableView will be shown in the window, like a "100%"-height value.

has anyone suggestions what i'm doing wrong?

regards,
robert

— asked September 28th 2010 by Robert Rockmann
  • 100%
  • auto
  • height
  • vertical layout
  • width
0 Comments

3 Answers

  • The following solved this issue for me:
    http://developer.appcelerator.com/question/3941/tableview-layout-is-improper-when-it-has-a-sibling

    — answered December 27th 2010 by Stefaan Ternier
    permalink
    0 Comments
  • Vertical layouts don't seem to accept 'auto' values in my experience. Especially if you've set the other value to an integer.

    I would consider why you think you need the height value at all…

    — answered September 28th 2010 by Todd Soligo
    permalink
    1 Comment
    • hey todd,
      thanks four your answer.

      i don't want to set the width/height values, but i want to use the vertical-layout.
      if i don't set the height/width values, the TableView doesn't appear in the window.
      have you got an idea how to solve this problem?

      — commented September 29th 2010 by Robert Rockmann
  • Try this:

    
    var table = Titanium.UI.createTableView({
        data: tableData,
        backgroundColor: 'blue',
        width: 200,
        top:0,
        bottom:0
    });
    
    — answered December 27th 2010 by Adriano Paladini
    permalink
    1 Comment
    • No, that doesn't work either. Layout:vertical should be one of the most useful pieces of this framework, but it's undocumented in the API docs, and doesn't work without all kinds of fiddly height settings on all of your elements. Very disappointed in Android/iPhone layout consistency.

      — commented October 17th 2011 by Tony Higham
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.