Position text inside a label (Titanium Mobile)
Is there a way to control the vertical alignment of text inside a label, e.g. say your label is 300px in height, but you want the text to start at 20px from the top edge.
Is there any way to control this?
Thanks!
3 Answers
-
I noticed there are TEXT_VERTICAL_ALIGNMENT_TOP,.._BOTTOM,… constants in the base Titanium.UI library, but what property can I couple it with to achieve the alignment or is this not possible within a label?
-
This worked for me, but it won't cut the text if it is longer (higher) then the height of the View:
this.infoContainer = Titanium.UI.createView({ top : 19, left : 62, width : 238, height : 28 }); this.infoLabel = Titanium.UI.createLabel({ height : 'auto', top : 0 }); this.infoContainer.add(this.infoLabel); this.view.add(this.infoContainer);
Result: Top-Vertical-Align of a text in a two line height element.
But the label will no longer truncate (and add a trailing '…') the text when the text is longer (higher).Any tricks to have top-align and truncate of the text?
-
I am interested in this, too. Even did not find an example in KitchenSink.