java.lang.Object | ||
↳ | com.neomades.ui.View | |
↳ | com.neomades.ui.RichTextLabel |
A RichTextLabel
can display HTML
strings.
To display plain text, use TextLabel
.
Be aware that RichTextLabel
is not a WebView
: some
complex tags and attributes may not be interpreted or ignored.
For example this is the case for style
tag and attribute and
font
tag.
<style>
tag will be completely ignored and its
content will not be displayed.<font>
tag will be ignored but its content will be
displayed.RichTextLabel
will display its HTML text even if there are
some HTML mistakes (missing ending tag, undefined tag, incomplete
attribute...). However in this case the result may be slightly different
between the platforms.
Hyperlink (<a>
tag) can be set in a
RichTextLabel
. The corresponding text will be highlighted and
the link can be clicked to open the page in the web browser.
In Android platform, the text is truncated if it cannot entirely be
displayed in the view (for example it may append in the case a
setHeight(int)
was done.
In iOS platform, before iOS 7.1, <a>
tag links
cannot be opened by tapping on them.
XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Attribute Name | Related Method | Description | |||||||||
font | setFont(Font) | Font resource id: Res.font.FONT_XXXX | |||||||||
text | setText(int) | Res.string.XXXX or a text | |||||||||
textColor | setTextColor(Color) | #AARRGGBB or a color | |||||||||
textSize | setTextSize(int) | a size in dp |
[Expand]
Inherited XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
RichTextLabel()
Builds a label with no text.
| |||||||||||
RichTextLabel(String label)
Builds a label with a given text.
| |||||||||||
RichTextLabel(int labelResId)
Builds a label with the text in the text resource file corresponding to an
id.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
setFont(Font font)
Sets the font of the label.
| ||||||||||
void |
setText(String text)
Sets the text of the label.
| ||||||||||
void |
setText(int resId)
Sets the text of the label from the text resource file using an id.
| ||||||||||
void |
setTextColor(Color color)
Sets the text color of this label.
| ||||||||||
void |
setTextSize(int size)
Set the default text size to the given value.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Builds a label with no text.
Builds a label with a given text. This text can be an HTML
string.
label | the new text |
---|
Builds a label with the text in the text resource file corresponding to an
id. This text can be an HTML
string.
labelResId | the string id representing the text of this label |
---|
Sets the font of the label.
If the text is from an HTML
string, the typeface and the style
will be applied to all HTML
tags. The size will be applied to
the p
tag. The other tags size will be scaled automatically
according to the font size.
font | the new font to set |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|---|
NullPointerException | if the font parameter is null |
Sets the text of the label. This text can be an HTML
string.
text | the new text |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Sets the text of the label from the text resource file using an id. This text
can be an HTML
string.
resId | the string id representing the text of this text label |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Sets the text color of this label.
If the color is also defined in the HTML
code, the behavior of
this method depends on the platform.
color | The color to set (with the alpha channel) |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Set the default text size to the given value.
If the text is from an HTML
string, it is the p
tag
that will take the given size. The other tags size will be scaled
automatically according to the new size.
size | the default text size |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|