public class AutofitHelper
extends java.lang.Object
TextView`s textSize to fit
within its bounds.| Modifier and Type | Class and Description |
|---|---|
static interface |
AutofitHelper.OnTextSizeChangeListener
When an object of a type is attached to an
AutofitHelper, its methods will be called
when the textSize is changed. |
| Modifier and Type | Method and Description |
|---|---|
AutofitHelper |
addOnTextSizeChangeListener(AutofitHelper.OnTextSizeChangeListener listener)
Adds an
AutofitHelper.OnTextSizeChangeListener to the list of those whose methods are called
whenever the TextView's textSize changes. |
static AutofitHelper |
create(android.widget.TextView view)
Creates a new instance of
AutofitHelper that wraps a TextView and enables
automatically sizing the text to fit. |
static AutofitHelper |
create(android.widget.TextView view,
android.util.AttributeSet attrs)
Creates a new instance of
AutofitHelper that wraps a TextView and enables
automatically sizing the text to fit. |
static AutofitHelper |
create(android.widget.TextView view,
android.util.AttributeSet attrs,
int defStyle)
Creates a new instance of
AutofitHelper that wraps a TextView and enables
automatically sizing the text to fit. |
int |
getMaxLines() |
float |
getMaxTextSize()
Returns the maximum size (in pixels) of the text.
|
float |
getMinTextSize()
Returns the minimum size (in pixels) of the text.
|
float |
getPrecision()
Returns the amount of precision used to calculate the correct text size to fit within its
bounds.
|
float |
getTextSize()
Returns the original text size of the View.
|
boolean |
isEnabled()
Returns whether or not automatically resizing text is enabled.
|
AutofitHelper |
removeOnTextSizeChangeListener(AutofitHelper.OnTextSizeChangeListener listener)
Removes the specified
AutofitHelper.OnTextSizeChangeListener from the list of those whose methods
are called whenever the TextView's textSize changes. |
AutofitHelper |
setEnabled(boolean enabled)
Set the enabled state of automatically resizing text.
|
AutofitHelper |
setMaxLines(int lines) |
AutofitHelper |
setMaxTextSize(float size)
Set the maximum text size to the given value, interpreted as "scaled pixel" units.
|
AutofitHelper |
setMaxTextSize(int unit,
float size)
Set the maximum text size to a given unit and value.
|
AutofitHelper |
setMinTextSize(float size)
Set the minimum text size to the given value, interpreted as "scaled pixel" units.
|
AutofitHelper |
setMinTextSize(int unit,
float size)
Set the minimum text size to a given unit and value.
|
AutofitHelper |
setPrecision(float precision)
Set the amount of precision used to calculate the correct text size to fit within its
bounds.
|
void |
setTextSize(float size)
Set the original text size of the View.
|
void |
setTextSize(int unit,
float size)
Set the original text size of the View.
|
public static AutofitHelper create(android.widget.TextView view)
AutofitHelper that wraps a TextView and enables
automatically sizing the text to fit.public static AutofitHelper create(android.widget.TextView view, android.util.AttributeSet attrs)
AutofitHelper that wraps a TextView and enables
automatically sizing the text to fit.public static AutofitHelper create(android.widget.TextView view, android.util.AttributeSet attrs, int defStyle)
AutofitHelper that wraps a TextView and enables
automatically sizing the text to fit.public AutofitHelper addOnTextSizeChangeListener(AutofitHelper.OnTextSizeChangeListener listener)
AutofitHelper.OnTextSizeChangeListener to the list of those whose methods are called
whenever the TextView's textSize changes.public AutofitHelper removeOnTextSizeChangeListener(AutofitHelper.OnTextSizeChangeListener listener)
AutofitHelper.OnTextSizeChangeListener from the list of those whose methods
are called whenever the TextView's textSize changes.public float getPrecision()
public AutofitHelper setPrecision(float precision)
precision - The amount of precision.public float getMinTextSize()
public AutofitHelper setMinTextSize(float size)
size - The scaled pixel size.public AutofitHelper setMinTextSize(int unit, float size)
unit - The desired dimension unit.size - The desired size in the given units.public float getMaxTextSize()
public AutofitHelper setMaxTextSize(float size)
size - The scaled pixel size.public AutofitHelper setMaxTextSize(int unit, float size)
unit - The desired dimension unit.size - The desired size in the given units.public int getMaxLines()
TextView.getMaxLines()public AutofitHelper setMaxLines(int lines)
TextView.setMaxLines(int)public boolean isEnabled()
public AutofitHelper setEnabled(boolean enabled)
public float getTextSize()
TextView.getTextSize()public void setTextSize(float size)
TextView.setTextSize(float)public void setTextSize(int unit,
float size)
TextView.setTextSize(int, float)