Get label height when height property is auto
I'm trying to get the current height of a label. This label got the 'auto' height property when I create it. I need to get the new height after changing for a bigger font. The only property I can get is 'auto', there's no way I can get the height in pixel.
I tried various solution like retrieving the size of the label but it doesn't work.
When auto the size I get is 0.
8 Answers
-
I think
label.size.height
should work for you. -
I think if you specify the width of label,then the label.height can works well.
var label = Ti.UI.createLabel({ text:"..." height: 'auto', width: 280 }); label.height //this will get the height according to the text of label
-
Instead of using a timeout, I would recommend using the window's open event instead.
myWindow.addEventListener('open', function(e) { var uiElementHeight = uiElement.size.height; // Other code here... })
-
I have this issue on the iPhone platform. For further development it would be nice if we could have getter setters method for objects inside titanium
-
I'm not 100% on this, but as far as I know there is no way to do that.
-
Thanks for your answer, too bad I cannot get this working
-
Which platform(s)?
-
I have the same issue with SDK 1.7.5 in Android, and nothing seems to work!!!!