|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.badlogic.gdx.scenes.scene2d.Actor
com.badlogic.gdx.scenes.scene2d.ui.Widget
com.badlogic.gdx.scenes.scene2d.ui.Label
public class Label
A text label, with optional word wrapping.
The preferred size of the label is determined by the actual text bounds, unless word wrap
is enabled.
Nested Class Summary | |
---|---|
static class |
Label.LabelStyle
The style for a label, see Label . |
Field Summary |
---|
Fields inherited from class com.badlogic.gdx.scenes.scene2d.Actor |
---|
actions, color, height, name, originX, originY, parent, rotation, scaleX, scaleY, stage, touchable, visible, width, x, y |
Constructor Summary | |
---|---|
Label(java.lang.CharSequence text,
Label.LabelStyle style)
|
|
Label(java.lang.CharSequence text,
Label.LabelStyle style,
java.lang.String name)
|
|
Label(java.lang.CharSequence text,
Skin skin)
|
|
Label(java.lang.CharSequence text,
java.lang.String fontName,
Color color,
Skin skin)
Creates a label, using a Label.LabelStyle that has a BitmapFont with the specified name from the skin and the specified
color. |
|
Label(java.lang.CharSequence text,
java.lang.String fontName,
java.lang.String colorName,
Skin skin)
Creates a label, using a Label.LabelStyle that has a BitmapFont with the specified name and the specified color from the
skin. |
|
Label(Skin skin)
|
Method Summary | |
---|---|
void |
draw(SpriteBatch batch,
float parentAlpha)
If this method is overridden, the super method or Widget.validate() should be called to ensure the widget is laid out. |
Color |
getColor()
|
float |
getPrefHeight()
|
float |
getPrefWidth()
|
Label.LabelStyle |
getStyle()
Returns the label's style. |
java.lang.CharSequence |
getText()
|
BitmapFont.TextBounds |
getTextBounds()
|
void |
layout()
Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child and calls Layout.invalidate() and then Layout.validate() on each one. |
void |
setAlignment(int wrapAlign)
|
void |
setAlignment(int labelAlign,
int lineAlign)
|
void |
setColor(Color tint)
|
void |
setColor(float color)
|
void |
setColor(float r,
float g,
float b,
float a)
|
void |
setStyle(Label.LabelStyle style)
|
void |
setText(java.lang.CharSequence text)
|
void |
setWrap(boolean wrap)
If false, the text will only wrap where it contains newlines (\n). |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.ui.Widget |
---|
getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, hit, invalidate, invalidateHierarchy, needsLayout, pack, setFillParent, toScreenCoordinates, touchDown, touchDragged, touchUp, validate |
Methods inherited from class com.badlogic.gdx.scenes.scene2d.Actor |
---|
act, action, clearActions, getStage, isMarkedToRemove, keyDown, keyTyped, keyUp, markToRemove, remove, scrolled, toLocalCoordinates, toString, touchMoved |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Label(Skin skin)
public Label(java.lang.CharSequence text, Skin skin)
public Label(java.lang.CharSequence text, java.lang.String fontName, Color color, Skin skin)
Label.LabelStyle
that has a BitmapFont with the specified name from the skin and the specified
color.
public Label(java.lang.CharSequence text, java.lang.String fontName, java.lang.String colorName, Skin skin)
Label.LabelStyle
that has a BitmapFont with the specified name and the specified color from the
skin.
public Label(java.lang.CharSequence text, Label.LabelStyle style)
public Label(java.lang.CharSequence text, Label.LabelStyle style, java.lang.String name)
Method Detail |
---|
public void setStyle(Label.LabelStyle style)
public Label.LabelStyle getStyle()
setStyle(LabelStyle)
is
called.
public void setText(java.lang.CharSequence text)
public java.lang.CharSequence getText()
public BitmapFont.TextBounds getTextBounds()
public void setWrap(boolean wrap)
public void setAlignment(int wrapAlign)
wrapAlign
- Aligns each line of text horizontally and all the text vertically.Align
public void setAlignment(int labelAlign, int lineAlign)
labelAlign
- Aligns all the text with the label widget.lineAlign
- Aligns each line of text (left, right, or center).Align
public void setColor(float color)
public void setColor(Color tint)
public void setColor(float r, float g, float b, float a)
public Color getColor()
public void layout()
Layout
Layout.invalidate()
and then Layout.validate()
on each one. Usually this should not be called directly, instead
Layout.validate()
should be used.
layout
in interface Layout
layout
in class Widget
public void draw(SpriteBatch batch, float parentAlpha)
Widget
Widget.validate()
should be called to ensure the widget is laid out.
draw
in class Widget
batch
- the spritebatch to render withparentAlpha
- the parent's alpha value.public float getPrefWidth()
getPrefWidth
in interface Layout
getPrefWidth
in class Widget
public float getPrefHeight()
getPrefHeight
in interface Layout
getPrefHeight
in class Widget
|
libgdx API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |