Titanium Community Questions & Answer Archive

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

Proper nesting of views with respect to positioning

I noticed that the UI module docs indicate a center property which is relative to the parent view.

Specifically: Ti.UI.ImageView

>center object a dictionary with properties x and y to indicate the center of the views position relative to the parent view

However, when I nest an image view inside another view which is positioned inside my "main" view for a window, this property seems to only respect the "root" view:

snippet of setup:

...
var dashboardView = Ti.UI.createView({
    size:{width:320,height:win1.getHeight()},
    top:0,bottom:0
});

...

var consoleView = Ti.UI.createView({
   size:{width:320,height:110},
   left:0,bottom:0
});

var forceImage = Ti.UI.createImageView({
    url:'../images/blue-circle.png',
    width:62,height:62,
    center:{x:160,y:0}
});

consoleView.add(forceImage);
dashboardView.add(consoleView);

I expect the forceImage to appear at the horizontal center and vertical top of the 110px high consoleView which is situated at the bottom of the dashboardView. Instead, forceImage appears horizontally centered with it's vertical center at the top of the window (the top half is cut off by the status bar).

If my understanding of the view hierarchy or positioning properties is incorrect please explain it's proper use. This is causing me great headache in implementing a flexible layout.

— asked March 15th 2010 by Robert Carlsen
  • center
  • layout
  • mobile
  • position
0 Comments

0 Answers

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.