java.lang.Object | ||
↳ | com.neomades.ui.View | |
↳ | com.neomades.ui.TextLabel |
A TextLabel
represents a text into Screen.
This class displays a simple text label.
By default, the following properties are applied to a new TextLabel:
MATCH_PARENT.
MATCH_CONTENT.
LEFT|TOP.
XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Attribute Name | Related Method | Description | |||||||||
contentAlignment | setContentAlignment(int) | A combination of alignment values (eg: TOP|LEFT) | |||||||||
font | setFont(Font) | Font resource id: Res.font.FONT_XXXX | |||||||||
lines | setLines(int) | Number of lines | |||||||||
marqueeEffect | setMarqueeEffect(boolean) | If the textlabel shows a horizontal scrolling text | |||||||||
text | setText(int) | Res.string.XXXX or a text | |||||||||
textColor | setTextColor(Color) | #AARRGGBB or a color | |||||||||
textSize | setTextSize(int) | a size in dp | |||||||||
underlineThickness | setUnderlineThickness(int) | eg: 10dp or 10 (dp is the default unit) |
[Expand]
Inherited XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
TextLabel()
Construct a label with no text
| |||||||||||
TextLabel(String text)
Constructs a label with the text given in parameter
| |||||||||||
TextLabel(int resId)
Constructs a label with the text given in parameter
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int |
getContentAlignment()
Returns the current text alignment of the button
| ||||||||||
String |
getText()
Returns the current text of this label.
| ||||||||||
Color |
getTextColor()
Returns the current text color of this label
| ||||||||||
void |
setContentAlignment(int alignment)
Sets the alignment of the text in the button.
| ||||||||||
void |
setFont(Font font)
Sets the font of the label
| ||||||||||
void |
setLines(int lines)
Sets the number of lines of this text label.
| ||||||||||
void |
setMarqueeEffect(boolean marquee)
Enables or disables the
"marquee" effect over this label. | ||||||||||
void |
setMaxLines(int maxLines)
Makes the
TextLabel at most this many lines tall. | ||||||||||
void |
setText(String text)
Sets the text of the label
| ||||||||||
void |
setText(int resId)
Sets the text of the label
| ||||||||||
void |
setTextColor(Color color)
Sets the text color of this text label
| ||||||||||
void |
setTextSize(int sizeInDp)
Sets the text size to a given value (in dp).
| ||||||||||
void |
setUnderlineThickness(int thicknessInDP)
Sets the underline thickness of this label.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
A combination of alignment values (eg: TOP|LEFT)
If the textlabel shows a horizontal scrolling text
eg: 10dp or 10 (dp is the default unit)
Construct a label with no text
Constructs a label with the text given in parameter
text | the new text |
---|
Constructs a label with the text given in parameter
resId | the string id representing the text of this text label |
---|
Returns the current text alignment of the button
Alignment
Returns the current text of this label. Returns an empty string ("") if there is no text.
Returns the current text color of this label
Sets the alignment of the text in the button. The alignment will be used only
if the text is smaller than the TextLabel size. (default :
TOP
|LEFT
)
In MATCH_CONTENT
mode, the
TextLabel
size is the same than the text size, then this alignment
property will be inefficient.
The parameter is a combination of values from Alignment
.
alignment | The new alignment of the label's text |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Sets the font of the label
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 number of lines of this text label.
If the text is longer than this number of lines, the text will be truncated.
If the text is smaller than this number of lines, empty lines will be displayed after the text to reach the number of lines.
This method uses the setHeight()
method, if a
setHeight()
have been use before it will be overwritten.
lines | number of lines. If 0, no lines will be displayed. If -1, the
number of lines displayed will rely on the text length and the
stretch property of the TextLabel (default). If < -1,
an exception will be raised. |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|---|
IllegalArgumentException | if lines is < -1 |
Enables or disables the "marquee"
effect over this label.
The text will be displayed in a Single line mode. If the text is longer than this TextLabel bounds, then the text will scroll from left to right automatically.
If the text's width is lower than the label's width in marquee mode, then the marquee will be disabled because the user can see all the text.
Note: If the number of lines is modified or if the text contains return carriage, this mode will be disabled.marquee | true to enable the "marquee" effect |
---|
Makes the TextLabel
at most this many lines tall.
Setting this value overrides any other (maximum) height
setting.
maxLines | number of lines at most. If 0, no lines will be displayed. If -1, no limit of maximum lines will be set (default). If < -1, an exception will be raised. |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|---|
IllegalArgumentException | if maxLines < -1 |
Sets the text of the label
text | the new text |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Sets the text of the label
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 text label
color | The color to set (with the alpha channel) |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Sets the text size to a given value (in dp).
sizeInDp | size to set to the text |
---|
Sets the underline thickness of this label.
A negative or zero value means no underlined label.
thicknessInDP | A negative or zero value means no underlined text, otherwise the parameter means the thickness of the line in DP units. |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|