public class GLabel extends GObject
GLabel class is a graphical object whose appearance
consists of a text string.| Modifier and Type | Field and Description |
|---|---|
static Typeface |
DEFAULT_FONT
The default font used to display strings.
|
| Constructor and Description |
|---|
GLabel()
Creates a new empty
GLabel object with its top-left corner at (0, 0). |
GLabel(int id)
Creates a new
GLabel object at with its top-left corner (0, 0),
initialized to contain the string with the specified resource ID. |
GLabel(int id,
float x,
float y)
Creates a new
GLabel object with its top-left corner at the specified position. |
GLabel(String str)
Creates a new
GLabel object at with its top-left corner (0, 0),
initialized to contain the specified string. |
GLabel(String str,
float x,
float y)
Creates a new
GLabel object with its top-left corner at the specified position. |
| Modifier and Type | Method and Description |
|---|---|
Typeface |
getFont()
Returns the font in which the
GLabel is displayed. |
float |
getFontSize()
Returns the font size currently used by this label.
|
int |
getFontStyle()
Returns this label's current font style.
|
float |
getHeight()
Returns the height of this string, as it appears on the display.
|
String |
getLabel()
Returns the string displayed by this object.
|
String |
getText()
Returns the string displayed by this object.
|
float |
getWidth()
Returns the width of this string, as it appears on the display.
|
void |
paint(Canvas canvas)
Implements the
paint operation for this graphical object. |
void |
setFont(String str)
Changes the font used to display the
GLabel as specified by
the string str. |
void |
setFont(Typeface font)
Changes the font used to display the
GLabel. |
void |
setFont(Typeface font,
float size)
Sets this GLabel to use the given font at the given size.
|
void |
setFont(Typeface fontFamily,
int style,
float size)
Sets this GLabel to use the given font at the given style and size.
|
void |
setFontSize(float size)
Sets this label to use a font of the given size.
|
void |
setFontStyle(int style)
Sets this label to use the given font style,
such as TypeFace.BOLD.
|
void |
setLabel(int id)
Changes the string stored within the
GLabel object, so that
a new text string appears on the display. |
void |
setLabel(String str)
Changes the string stored within the
GLabel object, so that
a new text string appears on the display. |
void |
setText(int id)
Changes the string stored within the
GLabel object, so that
a new text string appears on the display. |
void |
setText(String str)
Changes the string stored within the
GLabel object, so that
a new text string appears on the display. |
contains, contains, getBottomY, getBounds, getCenterX, getCenterY, getColor, getGCanvas, getLocation, getPaint, getRightX, getSize, getX, getY, intersects, isVisible, moveBy, moveByPolar, moveTo, moveTo, moveToPolar, repaint, sendBackward, sendForward, sendToBack, sendToFront, setBottomY, setCanvas, setColor, setGCanvas, setLocation, setLocation, setPaint, setRightX, setVisible, setX, setY, toString, translatepublic GLabel()
GLabel object with its top-left corner at (0, 0).public GLabel(String str)
GLabel object at with its top-left corner (0, 0),
initialized to contain the specified string.str - The initial contents of the GLabelpublic GLabel(String str, float x, float y)
GLabel object with its top-left corner at the specified position.str - The initial contents of the GLabelx - The x-coordinate of the label originy - The y-coordinate of the baseline for the labelpublic GLabel(@StringRes int id)
GLabel object at with its top-left corner (0, 0),
initialized to contain the string with the specified resource ID.id - The resource ID of the initial contents of the GLabelpublic GLabel(@StringRes int id, float x, float y)
GLabel object with its top-left corner at the specified position.id - The ID of the resource string for the initial contents of the GLabelx - The x-coordinate of the label originy - The y-coordinate of the baseline for the labelpublic Typeface getFont()
GLabel is displayed.public int getFontStyle()
public String getLabel()
public String getText()
public void paint(Canvas canvas)
paint operation for this graphical object. This method
is not called directly by clients.public float getWidth()
public float getHeight()
public float getFontSize()
public void setFontStyle(int style)
public void setFont(Typeface font)
GLabel. This call will
usually change the size of the displayed object and will therefore affect
the result of calls to getSize
and getBounds.font - A Font object indicating the new fontpublic void setFont(Typeface font, float size)
public void setFont(Typeface fontFamily, int style, float size)
public void setFont(String str)
GLabel as specified by
the string str.str - A String specifying the new fontpublic void setFontSize(float size)
public void setLabel(@StringRes int id)
GLabel object, so that
a new text string appears on the display.id - The new string to display's resource IDpublic void setLabel(String str)
GLabel object, so that
a new text string appears on the display.str - The new string to displaypublic void setText(@StringRes int id)
GLabel object, so that
a new text string appears on the display.id - The new string to display's IDpublic void setText(String str)
GLabel object, so that
a new text string appears on the display.str - The new string to display