How to break lines and format labels
Johan Lund posted in Developing in Bindows on November 10th, 2010
If you have ever needed to put a line break into the text of a BiLabel you have probably experienced that a simple \n character doesn’t work. In this post I will show you a couple of ways you can use to control the formatting of your labels.
First let’s examine the label.
You can either put the text into the text property:
or inside the tag:
In the last example, where the text is put into the tag, you can get a line break simply by pressing Enter in your code, like this:
So far, we have been using the ”text” property of the BiLabel to give it simple text, however, we can also enter fully formatted HTML code via the HTML property, like this:
The trick is to use namespace to have nicely formatted XHTML right inside the markup, that is inside the tag.
First, let’s declare the namespace in the application tag:
Then, we can use it like this:
The result of the above code would look like this: