iPhone/Android: Better solution than absolute positioning?
What's a good way to position items in a window/view?
For example, I'm trying to put together a simple form with multiple input fields. Most of the code I found uses absolute positioning (left: 10, top:40). That doesn't seem very portable - android already has multiple screen sizes, and iPhone/iPad seems headed that way.
Are there css-like floats? Or other mechanisms for positioning things in a way that responds well to multiple orientations or screen sizes?
1 Answer
-
You can use horizontal and vertical layouts like this:
var container = Titanium.UI.createView({ layout: 'vertical' }); var input_1 = Titanium.UI.createTextField({ top: 10, left: 10, width: 300, height: 24 }); container.add(input_1); var input_2 = Titanium.UI.createTextField({ top: 10, left: 10, width: 300, height: 24 }); container.add(input_2);
The inputs will now be positioned underneath each other.