Modifier and Type | Class and Description |
---|---|
static class |
Label.LabelStyle
The style for a label, see
Label . |
Constructor and Description |
---|
Label(CharSequence text,
Label.LabelStyle style) |
Label(CharSequence text,
Skin skin) |
Label(CharSequence text,
Skin skin,
String styleName) |
Label(CharSequence text,
Skin skin,
String fontName,
Color color)
Creates a label, using a
Label.LabelStyle that has a BitmapFont with the specified name from the skin and the specified
color. |
Label(CharSequence text,
Skin skin,
String fontName,
String colorName)
Creates a label, using a
Label.LabelStyle that has a BitmapFont with the specified name and the specified color from the
skin. |
Modifier and Type | Method and Description |
---|---|
void |
draw(Batch batch,
float parentAlpha)
If this method is overridden, the super method or
Widget.validate() should be called to ensure the widget is laid out. |
float |
getFontScaleX() |
float |
getFontScaleY() |
GlyphLayout |
getGlyphLayout() |
int |
getLabelAlign() |
int |
getLineAlign() |
float |
getPrefHeight() |
float |
getPrefWidth() |
Label.LabelStyle |
getStyle()
Returns the label's style.
|
StringBuilder |
getText() |
void |
invalidate()
Invalidates this actor's layout, causing
Layout.layout() to happen the next time Layout.validate() is called. |
void |
layout()
Computes and caches any information needed for drawing and, if this actor has children, positions and sizes each child,
calls
Layout.invalidate() on any each child whose width or height has changed, and calls Layout.validate() on each
child. |
void |
setAlignment(int alignment) |
void |
setAlignment(int labelAlign,
int lineAlign) |
void |
setEllipsis(boolean ellipsis)
When true the text will be truncated "..." if it does not fit within the width of the label.
|
void |
setEllipsis(String ellipsis)
When non-null the text will be truncated "..." if it does not fit within the width of the label.
|
void |
setFontScale(float fontScale) |
void |
setFontScale(float fontScaleX,
float fontScaleY) |
void |
setFontScaleX(float fontScaleX) |
void |
setFontScaleY(float fontScaleY) |
void |
setStyle(Label.LabelStyle style) |
void |
setText(CharSequence newText) |
void |
setWrap(boolean wrap)
If false, the text will only wrap where it contains newlines (\n).
|
boolean |
textEquals(CharSequence other) |
String |
toString() |
getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, invalidateHierarchy, needsLayout, pack, setFillParent, setLayoutEnabled, validate
act, addAction, addCaptureListener, addListener, clear, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebug, fire, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasParent, hit, isAscendantOf, isDescendantOf, isTouchable, isVisible, localToAscendantCoordinates, localToParentCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, remove, removeAction, removeCaptureListener, removeListener, rotateBy, scaleBy, scaleBy, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setUserObject, setVisible, setWidth, setX, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront
public Label(CharSequence text, Skin skin)
public Label(CharSequence text, Skin skin, String styleName)
public Label(CharSequence text, Skin skin, String fontName, Color color)
Label.LabelStyle
that has a BitmapFont with the specified name from the skin and the specified
color.public Label(CharSequence text, Skin skin, String fontName, String colorName)
Label.LabelStyle
that has a BitmapFont with the specified name and the specified color from the
skin.public Label(CharSequence text, Label.LabelStyle style)
public void setStyle(Label.LabelStyle style)
public Label.LabelStyle getStyle()
setStyle(LabelStyle)
is
called.public void setText(CharSequence newText)
newText
- May be null, "" will be used.public boolean textEquals(CharSequence other)
public StringBuilder getText()
public void invalidate()
Layout
Layout.layout()
to happen the next time Layout.validate()
is called. This
method should be called when state changes in the actor that requires a layout but does not change the minimum, preferred,
maximum, or actual size of the actor (meaning it does not affect the parent actor's layout).invalidate
in interface Layout
invalidate
in class Widget
public void layout()
Layout
Layout.invalidate()
on any each child whose width or height has changed, and calls Layout.validate()
on each
child. This method should almost never be called directly, instead Layout.validate()
should be used.public void draw(Batch batch, float parentAlpha)
Widget
Widget.validate()
should be called to ensure the widget is laid out.public float getPrefWidth()
getPrefWidth
in interface Layout
getPrefWidth
in class Widget
public float getPrefHeight()
getPrefHeight
in interface Layout
getPrefHeight
in class Widget
public GlyphLayout getGlyphLayout()
public void setWrap(boolean wrap)
When wrap is enabled, the label's preferred height depends on the width of the label. In some cases the parent of the label will need to layout twice: once to set the width of the label and a second time to adjust to the label's new preferred height.
public int getLabelAlign()
public int getLineAlign()
public void setAlignment(int alignment)
alignment
- Aligns all the text within the label (default left center) and each line of text horizontally (default
left).Align
public void setAlignment(int labelAlign, int lineAlign)
labelAlign
- Aligns all the text within the label (default left center).lineAlign
- Aligns each line of text horizontally (default left).Align
public void setFontScale(float fontScale)
public void setFontScale(float fontScaleX, float fontScaleY)
public float getFontScaleX()
public void setFontScaleX(float fontScaleX)
public float getFontScaleY()
public void setFontScaleY(float fontScaleY)
public void setEllipsis(String ellipsis)
public void setEllipsis(boolean ellipsis)
Copyright © 2016. All rights reserved.