Titanium Community Questions & Answer Archive

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

Padding on a Label

Hi all

How do I put on padding on a label? I want my label to look like the iPhone table grouped.


Any ideas?

— asked August 6th 2010 by Caspar Jespersen
  • iphone
  • lable
  • padding

7 Answers

  • you can create a standard view and add a label to it, having its left property set to the value a padding would have

    var vLabel = Ti.UI.createView({width: 300, height: 35, top: 120});

    var lLabel = Ti.UI.createLabel({left: 10, right: 10, text: 'my text', height: 30});


    — answered August 6th 2010 by Christian Sigl
    1 Comment
    • hi, i have another question on such issue, i'm in android, label's paddingLeft/paddingRight cant use;

      as you see, the code create label in fixed length/width, i need the label's length auto expended by it's text length;
      like http://lrg131.zpcdn.com/1/7054/45148651.bc9f4f.jpg anyone have idea on how to make that?

      — commented January 30th 2012 by de huang
  • @Christian Sigl - Thanks, that worked for me (better on system resources than using webView).

    @Steven Ng - I really hope you got an answer to that question from 4 months ago. I'm new to Titanium, but I added the property of backgroundColor to the label and that gave it a background color.

    — answered October 31st 2011 by Rafferty Pendery
  • width : 'auto'
    gives you automatic padding i.e after filling 1 st line content will go to next line automatically within your row of specified tableview.
    if you want the content of your data should be within one line only, then use height : '20' (aprox), all data will be shrink and out of scope letters will be wrap up by "…."

    moreover if you want to add swipe delete event like iphone you could set width property of your label in row of table as
    width : Titanium.Platform.displayCaps.platformWidth - 40,

    — answered January 22nd 2013 by Sourabh Kaley
  • We've created an Titanium iOS label control that support inset padding and bunch of other goodies that standard Ti label is missing, while keeping the resource/memory usage low. You can try it out here.

    — answered April 5th 2013 by Ondrej Urik
  • Hey Caspar or anyone can you share how you created padded label or webview with a colored background?

    — answered July 4th 2011 by Steven Ng
  • Nevermind. I just did a WebView.

    — answered August 6th 2010 by Caspar Jespersen
  • I just do this:

    var label = Ti.UI.createLabel({
        text: "    " + theText + "    ",

    The quotes contain 4 spaces (1 Tab). You can set the number of spaces as per your liking.

    — answered May 4th 2012 by Nikhil Nigade
    • Nikhil,

      That should only put a space before and after the label. So if the label was more than one line there would be an indent on the first line but the second line (and any subsequent lines) would not be indented.

      — commented May 13th 2012 by Forrest Frazier
    • This was a great answer for a one line label, thanks

      — commented April 21st 2013 by Thomas Stalcup Jr
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.