MotionLabel
public class MotionLabel extends View implements FloatLayout
This class is designed to create complex animated single line text in MotionLayout. Its API are designed with animation in mine. for example it uses setTextPanX(float x) where 0 is centered -1 is left +1 is right It supports the following features:
- color outlines
- Textured text
- Blured Textured Text
- Scrolling of Texture in text
- PanX, PanY instead of Gravity
Summary
Public constructors |
|---|
MotionLabel(Context context) |
MotionLabel(Context context, @Nullable AttributeSet attrs) |
MotionLabel( |
Public methods |
|
|---|---|
float |
getRound()Get the corner radius of curvature NaN = RoundPercent in effect. |
float |
Get the fractional corner radius of curvature. |
float |
if set the font is rendered to polygons at this size and then scaled to the size set by textSize. |
float |
Gets the pan from the center pan of 1 the image is "all the way to the right" if the images width is greater than the screen width, pan = 1 results in the left edge lining up if the images width is less than the screen width, pan = 1 results in the right edges lining up if image width == screen width it does nothing |
float |
gets the pan from the center pan of 1 the image is "all the way to the bottom" if the images width is greater than the screen height, pan = 1 results in the bottom edge lining up if the images width is less than the screen height, pan = 1 results in the top edges lining up if image height == screen height it does nothing |
float |
gets the rotation |
float |
gets the zoom where 1 scales the image just enough to fill the view |
int |
|
float |
Pan the Texture in the text in the x axis. |
float |
Pan the Texture in the text in the y axis. |
float |
Pan the Texture in the text in the y axis. |
float |
get the width of the texture. |
Typeface |
|
void |
layout(float l, float t, float r, float b)To convert to regular layout l = (int)(0.5f + lf); You are expected to do your own measure if you need it. |
void |
layout(int l, int t, int r, int b) |
void |
setGravity(int gravity)Sets the horizontal alignment of the text and the vertical gravity that will be used when there is extra space in the TextView beyond what is required for the text itself. |
void |
@RequiresApi(value = Build.VERSION_CODES.LOLLIPOP)Set the corner radius of curvature |
void |
@RequiresApi(value = Build.VERSION_CODES.LOLLIPOP)Set the corner radius of curvature as a fraction of the smaller side. |
void |
setScaleFromTextSize(float size)if set the font is rendered to polygons at this size and then scaled to the size set by textSize. |
void |
setText(CharSequence text)set text |
void |
setTextBackgroundPanX(float pan)sets the pan from the center pan of 1 the image is "all the way to the right" if the images width is greater than the screen width, pan = 1 results in the left edge lining up if the images width is less than the screen width, pan = 1 results in the right edges lining up if image width == screen width it does nothing |
void |
setTextBackgroundPanY(float pan)sets the pan from the center pan of 1 the image is "all the way to the bottom" if the images width is greater than the screen height, pan = 1 results in the bottom edge lining up if the images width is less than the screen height, pan = 1 results in the top edges lining up if image height == screen height it does nothing |
void |
setTextBackgroundRotate(float rotation)sets the rotation angle of the image in degrees |
void |
setTextBackgroundZoom(float zoom)sets the zoom where 1 scales the image just enough to fill the view |
void |
setTextFillColor(int color)Set the color of the text. |
void |
setTextOutlineColor(int color)Sets the color of the text outline. |
void |
setTextOutlineThickness(float width)Set outline thickness |
void |
setTextPanX(float textPanX)Pan the Texture in the text in the x axis. |
void |
setTextPanY(float textPanY)Pan the Texture in the text in the y axis. |
void |
setTextSize(float size)set text size |
void |
setTextureHeight(float mTextureHeight)set the height of the texture. |
void |
setTextureWidth(float mTextureWidth)set the width of the texture. |
void |
setTypeface(Typeface tf)set the typeface |
Protected methods |
|
|---|---|
void |
|
void |
onMeasure(int widthMeasureSpec, int heightMeasureSpec) |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Inherited methods |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
MotionLabel
public MotionLabel(
Context context,
@Nullable AttributeSet attrs,
int defStyleAttr
)
Public methods
getRound
public float getRound()
Get the corner radius of curvature NaN = RoundPercent in effect.
| Returns | |
|---|---|
float |
Radius of curvature |
getRoundPercent
public float getRoundPercent()
Get the fractional corner radius of curvature.
| Returns | |
|---|---|
float |
Fractional radius of curvature with respect to smallest size |
getScaleFromTextSize
public float getScaleFromTextSize()
if set the font is rendered to polygons at this size and then scaled to the size set by textSize.
| Returns | |
|---|---|
float |
size to pre render font or NaN if not used. |
getTextBackgroundPanX
public float getTextBackgroundPanX()
Gets the pan from the center pan of 1 the image is "all the way to the right" if the images width is greater than the screen width, pan = 1 results in the left edge lining up if the images width is less than the screen width, pan = 1 results in the right edges lining up if image width == screen width it does nothing
| Returns | |
|---|---|
float |
the pan in X. Where 0 is centered = Float. NaN if not set |
getTextBackgroundPanY
public float getTextBackgroundPanY()
gets the pan from the center pan of 1 the image is "all the way to the bottom" if the images width is greater than the screen height, pan = 1 results in the bottom edge lining up if the images width is less than the screen height, pan = 1 results in the top edges lining up if image height == screen height it does nothing
| Returns | |
|---|---|
float |
pan in y. Where 0 is centered NaN if not set |
getTextBackgroundRotate
public float getTextBackgroundRotate()
gets the rotation
| Returns | |
|---|---|
float |
the rotation in degrees |
getTextBackgroundZoom
public float getTextBackgroundZoom()
gets the zoom where 1 scales the image just enough to fill the view
| Returns | |
|---|---|
float |
the zoom factor |
getTextPanX
public float getTextPanX()
Pan the Texture in the text in the x axis.
| Returns | |
|---|---|
float |
pan of the Text -1 = left 0 = center +1 = right |
getTextPanY
public float getTextPanY()
Pan the Texture in the text in the y axis.
| Returns | |
|---|---|
float |
the pan value 0 being centered in the center of screen. |
getTextureHeight
public float getTextureHeight()
Pan the Texture in the text in the y axis.
| Returns | |
|---|---|
float |
pan of the Text -1 = top 0 = center +1 = bottom |
getTextureWidth
public float getTextureWidth()
get the width of the texture. Setting Float.NaN is the default Use the view size.
| Returns | |
|---|---|
float |
the width of the texture |
getTypeface
public Typeface getTypeface()
| Returns | |
|---|---|
Typeface |
the current typeface and style in which the text is being displayed. |
| See also | |
|---|---|
setTypeface |
layout
public void layout(float l, float t, float r, float b)
To convert to regular layout l = (int)(0.5f + lf); You are expected to do your own measure if you need it. This will be called only during animation.
setGravity
public void setGravity(int gravity)
Sets the horizontal alignment of the text and the vertical gravity that will be used when there is extra space in the TextView beyond what is required for the text itself.
ref android.R.styleable#TextView_gravity
| See also | |
|---|---|
Gravity |
setRound
@RequiresApi(value = Build.VERSION_CODES.LOLLIPOP)
public void setRound(float round)
Set the corner radius of curvature
| Parameters | |
|---|---|
float round |
the radius of curvature NaN = default meaning roundPercent in effect |
setRoundPercent
@RequiresApi(value = Build.VERSION_CODES.LOLLIPOP)
public void setRoundPercent(float round)
Set the corner radius of curvature as a fraction of the smaller side. For squares 1 will result in a circle
| Parameters | |
|---|---|
float round |
the radius of curvature as a fraction of the smaller width |
setScaleFromTextSize
public void setScaleFromTextSize(float size)
if set the font is rendered to polygons at this size and then scaled to the size set by textSize. This allows smooth efficient animation of fonts size.
| Parameters | |
|---|---|
float size |
the size to pre render the font or NaN if not used. |
setTextBackgroundPanX
public void setTextBackgroundPanX(float pan)
sets the pan from the center pan of 1 the image is "all the way to the right" if the images width is greater than the screen width, pan = 1 results in the left edge lining up if the images width is less than the screen width, pan = 1 results in the right edges lining up if image width == screen width it does nothing
| Parameters | |
|---|---|
float pan |
sets the pan in X. Where 0 is centered |
setTextBackgroundPanY
public void setTextBackgroundPanY(float pan)
sets the pan from the center pan of 1 the image is "all the way to the bottom" if the images width is greater than the screen height, pan = 1 results in the bottom edge lining up if the images width is less than the screen height, pan = 1 results in the top edges lining up if image height == screen height it does nothing
| Parameters | |
|---|---|
float pan |
sets the pan in X. Where 0 is centered |
setTextBackgroundRotate
public void setTextBackgroundRotate(float rotation)
sets the rotation angle of the image in degrees
| Parameters | |
|---|---|
float rotation |
angle in degrees |
setTextBackgroundZoom
public void setTextBackgroundZoom(float zoom)
sets the zoom where 1 scales the image just enough to fill the view
| Parameters | |
|---|---|
float zoom |
the zoom factor |
setTextFillColor
public void setTextFillColor(int color)
Set the color of the text.
| Parameters | |
|---|---|
int color |
the color of the text |
setTextOutlineColor
public void setTextOutlineColor(int color)
Sets the color of the text outline.
| Parameters | |
|---|---|
int color |
the color of the outline of the text |
setTextOutlineThickness
public void setTextOutlineThickness(float width)
Set outline thickness
| Parameters | |
|---|---|
float width |
setTextPanX
public void setTextPanX(float textPanX)
Pan the Texture in the text in the x axis.
| Parameters | |
|---|---|
float textPanX |
pan of the Text -1 = left 0 = center +1 = right |
setTextPanY
public void setTextPanY(float textPanY)
Pan the Texture in the text in the y axis.
| Parameters | |
|---|---|
float textPanY |
pan of the Text -1 = top 0 = center +1 = bottom |
setTextSize
public void setTextSize(float size)
set text size
| Parameters | |
|---|---|
float size |
the size of the text |
| See also | |
|---|---|
setTextSize |
setTextureHeight
public void setTextureHeight(float mTextureHeight)
set the height of the texture. Setting Float.NaN is the default Use the view size.
| Parameters | |
|---|---|
float mTextureHeight |
the height of the texture |
setTextureWidth
public void setTextureWidth(float mTextureWidth)
set the width of the texture. Setting Float.NaN is the default Use the view size
| Parameters | |
|---|---|
float mTextureWidth |
set the width of the texture Float.NaN clears setting |
setTypeface
public void setTypeface(Typeface tf)
set the typeface
| Parameters | |
|---|---|
Typeface tf |