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?
Caspar
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});
vLabel.add(lLabel);
-
@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.
-
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, -
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.
-
Hey Caspar or anyone can you share how you created padded label or webview with a colored background?
-
Nevermind. I just did a WebView.
-
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.