Titanium Community Questions & Answer Archive

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

Text aligment within the Label

is it possible to justify text to the left-right sides - sililar for example like in CSS: text-align:justify ?

— asked April 11th 2010 by Edvard Arutyunyan
  • createlabel
  • iphone
  • text
  • ui

5 Answers

  • textAlign:'center'

    — answered October 9th 2010 by Ben Hornedo
  • Have you found something to justify text in a Label ?
    I am searching for something to justify text too.


    — answered September 16th 2010 by Guillaume Ferrand
    1 Comment
    • no, unfortunatelly not!

      — commented October 9th 2010 by Edvard Arutyunyan
  • Still no way to justify text in a label?

    — answered January 28th 2011 by Arthur Roussel
  • Depends on why you want to do this. By default labels center their text on whatever view they are put on. It's only once you position the label say, 20 from the left, that the text is then aligned left. If say, you wanted to align the text on an image that itself was 20 from the left, here's what you could do:

    set a second view under your image with the same width and at the same distance from the left, center or right

    add the label to the second view and do not set its distance from left, right or center.

    The label should now appear centered on the image.

    — answered October 19th 2012 by David Rempel

    — answered April 11th 2013 by Tsvetan Nikolov
    • After multiple attempts to test this property, I haven't found that it affects anything, i.e. I can't get it to work.

      — commented May 1st 2014 by Michael Stelly
    • I rescind the above comment. Something else blocked the alignment. So, for the record, use either textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER or textAlign: 'center'

      — commented May 1st 2014 by Michael Stelly
    • However, I'm not able to get either property setting to work for android. :(

      — commented May 1st 2014 by Michael Stelly
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.