Search code examples
stringappcelerator

Is it possible to determine a string's width in Appcelerator?


I'm trying to determine the length of a String so I can dynamically layout some Labels. In iOS I would use:
CGSize size = [string sizeWithFont:font];
Is it possible to do this with the Appcelerator API or is there another way to do this type of dynamic layout?


Solution

  • var win = Ti.UI.createWindow({
        'layout': 'horizontal'
    });
    

    https://github.com/appcelerator/titanium_mobile/blob/master/demos/KitchenSink/Resources/examples/horizontal_layout.js