Titanium Community Questions & Answer Archive

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

Such as thing as padding ?

I have an app that has a a view with rounded corners, and inside that view I have added a text box. In the text box, I have a left:10, but it seems to but up against it. I've tried left:50 just to see a difference, but it stays in the same spot.

var controlsView = Ti.UI.createView({

    width:270,
  top:25,
  height:'auto'

});

var tf1 = Titanium.UI.createTextField({
    width:250,
    fontSize:10,
    backgroundColor:'#ffffff',
    height:45,
    left:10,
    top:10,
    borderRadius:5,
    autocorrect:true,
    hintText:'Add a quick title...'
    });


controlsView.add(tf1);
— asked October 26th 2010 by Josh Lewis
  • padding
0 Comments

1 Answer

  • Accepted Answer

    Josh,

    In your posted code, the left:10 refers to where the text field boundaries will appear within the controlsView bounds. It does not impact where text will appear within the bounds of the text field itself. For that, try adding the paddingLeft and paddingRight properties. Perhaps:

    left:10,
    top:10,
    borderRadius:5,
    paddingLeft:5,
    paddingRight:5,

    etc

    — answered October 26th 2010 by Doug Handy
    permalink
    6 Comments
    • It seems like Android doesn't support the padding properties.

      — commented January 21st 2012 by Justin Toth
    • It seems android doens't support very much (titanium-wise)

      — commented January 24th 2012 by Robbe Clerckx
    • It seems Titanium doesn't support very much (Android-wise).

      — commented February 10th 2012 by Owen Borseth
    • +1 to all ;)

      — commented February 17th 2012 by Chris Dunstall
    • +1 as well. Padding is not working on views, textareas, or really anything. I've tried using PX, DP, and straight number units; nothing works. Anyone have a solution here?

      — commented May 4th 2012 by Joshua Lambert
    • This is pretty pathetic. No support for Android, years in? No support for mobile web, years in? What, exactly, are you guys doing over there? We're talking some pretty basic features here. Padding? That's not exactly obscure. And I found a bug report for this that's almost two years old. And it wasn't just padding. It included several very basic attributes that everyone uses.

      What, exactly, are my alternatives? What's the best way to get around this? In short: how do I apply padding to text fields for anything not iOS? I'm not trying to make JUST an iPhone app. That's not why we chose Appcelerator…

      — commented October 31st 2013 by Vince Bullinger
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.