Padding in label???
Hi i have a label like this
var label = Ti.UI.createLabel({
text: 'TITANIUM',
font:{fontWeight:'bold',fontSize:14},
left:60,
color:'white',
borderRadius:8,
backgroundGradient:{type:'linear',
colors:['#101010','#555555'],
startPoint:{x:0,y:0},
endPoint:{x:2,y:60},
backFillStart:false},
height:30,
width:150,
paddingLeft:5
});
i want to add left padding…How can i do it.??(for iphone)
4 Answers
-
The answer is easy and works very well. Instead of putting the label in a view. Put the label in another label. A label IS a view anyway but it has a really useful characteristic, it tries to stay as small as possible and so it will expand to fit the objects within it, so don't give the outer label any height or width. If you put a label in a label and then put top, bottom, left and right values on the inner label, you will have your padding. You can put all sorts of things in a label , (I have even used it to contain button bars!!)
-
Not sure if there is a better way, but I've created a view and then put the label int he view and used left, right, top, bottom of the label to act as a padding within the view.
I also think the marketplace has a styleable label. https://marketplace.appcelerator.com/apps/790
-
I found the quickest way to add some extra spacing below a padding a label was to add carriage returns.
Using the example as basis:
var label = Ti.UI.createLabel({ text: 'TITANIUM' + '\n\n\n' });
-
use
Lable.backgroundPaddingLeft :5
it will extend the background color or image to left. it works only on iPhone