public class TextDrawable
extends android.graphics.drawable.Drawable
android.widget.TextView for displaying and formatting text.
Optionally, a Path may be supplied on which to draw the text.
A TextDrawable has an intrinsic size equal to that required to draw all
the text it has been supplied, when possible. In cases where a Path
has been supplied, the caller must explicitly call
setBounds() to provide the Drawable
size based on the Path constraints.| Constructor and Description |
|---|
TextDrawable(android.content.Context context) |
| Modifier and Type | Method and Description |
|---|---|
void |
draw(android.graphics.Canvas canvas) |
int |
getIntrinsicHeight() |
int |
getIntrinsicWidth() |
int |
getOpacity() |
CharSequence |
getText()
Return the text currently being displayed
|
android.text.Layout.Alignment |
getTextAlign()
Return the current text alignment setting
|
float |
getTextScaleX()
Return the horizontal stretch factor of the text
|
float |
getTextSize()
Return the current text size, in pixels
|
android.graphics.Typeface |
getTypeface()
Return the current typeface and style that the Paint
using for display.
|
boolean |
isStateful() |
protected void |
onBoundsChange(android.graphics.Rect bounds) |
protected boolean |
onStateChange(int[] state) |
void |
setAlpha(int alpha) |
void |
setColorFilter(android.graphics.ColorFilter cf) |
void |
setText(CharSequence text)
Set the text that will be displayed
|
void |
setTextAlign(android.text.Layout.Alignment align)
Set the text alignment.
|
void |
setTextColor(android.content.res.ColorStateList colorStateList)
Set the text color as a state list
|
void |
setTextColor(int color)
Set a single text color for all states
|
void |
setTextPath(android.graphics.Path path)
Optional Path object on which to draw the text.
|
void |
setTextScaleX(float size)
Set the horizontal stretch factor of the text
|
void |
setTextSize(float size)
Set the text size.
|
void |
setTextSize(int unit,
float size)
Set the text size, using the supplied complex units
|
void |
setTypeface(android.graphics.Typeface tf)
Sets the typeface and style in which the text should be displayed.
|
void |
setTypeface(android.graphics.Typeface tf,
int style)
Sets the typeface and style in which the text should be displayed,
and turns on the fake bold and italic bits in the Paint if the
Typeface that you provided does not have all the bits in the
style that you specified.
|
clearColorFilter, copyBounds, copyBounds, createFromPath, createFromResourceStream, createFromResourceStream, createFromStream, createFromXml, createFromXmlInner, getBounds, getCallback, getChangingConfigurations, getConstantState, getCurrent, getLevel, getMinimumHeight, getMinimumWidth, getPadding, getState, getTransparentRegion, inflate, invalidateSelf, isVisible, jumpToCurrentState, mutate, onLevelChange, resolveOpacity, scheduleSelf, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setDither, setFilterBitmap, setLevel, setState, setVisible, unscheduleSelfpublic void setText(CharSequence text)
text - Text to displaypublic CharSequence getText()
public float getTextSize()
public void setTextSize(float size)
size - Text size value, in sppublic void setTextSize(int unit,
float size)
unit - Units for the text size, such as dp or spsize - Text size valuepublic float getTextScaleX()
public void setTextScaleX(float size)
size - Text scale factorpublic android.text.Layout.Alignment getTextAlign()
public void setTextAlign(android.text.Layout.Alignment align)
align - Text alignment value. Should be set to one of:
Layout.Alignment.ALIGN_NORMAL,
Layout.Alignment.ALIGN_NORMAL,
Layout.Alignment.ALIGN_OPPOSITE.public void setTypeface(android.graphics.Typeface tf)
setTypeface(android.graphics.Typeface, int) to get the appearance
that you actually want.public void setTypeface(android.graphics.Typeface tf,
int style)
public android.graphics.Typeface getTypeface()
public void setTextColor(int color)
color - Color value such as
Color.WHITE or Color.argb(int, int, int, int)public void setTextColor(android.content.res.ColorStateList colorStateList)
colorStateList - ColorStateList of text colors, such as inflated from an R.color resourcepublic void setTextPath(android.graphics.Path path)
setBounds() before
applying this TextDrawable to any View.
Calling this method with null will remove any Path currently attached.protected void onBoundsChange(android.graphics.Rect bounds)
onBoundsChange in class android.graphics.drawable.Drawablepublic boolean isStateful()
isStateful in class android.graphics.drawable.Drawableprotected boolean onStateChange(int[] state)
onStateChange in class android.graphics.drawable.Drawablepublic int getIntrinsicHeight()
getIntrinsicHeight in class android.graphics.drawable.Drawablepublic int getIntrinsicWidth()
getIntrinsicWidth in class android.graphics.drawable.Drawablepublic void draw(android.graphics.Canvas canvas)
draw in class android.graphics.drawable.Drawablepublic void setAlpha(int alpha)
setAlpha in class android.graphics.drawable.Drawablepublic int getOpacity()
getOpacity in class android.graphics.drawable.Drawablepublic void setColorFilter(android.graphics.ColorFilter cf)
setColorFilter in class android.graphics.drawable.DrawableCopyright © 2013. All Rights Reserved.