MotionLabel
class MotionLabel : View, 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!, attrs: AttributeSet?) |
MotionLabel(context: Context!, attrs: AttributeSet?, defStyleAttr: Int) |
Public functions |
|
|---|---|
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! |
|
Unit |
To convert to regular layout l = (int)(0.5f + lf); You are expected to do your own measure if you need it. |
Unit |
|
Unit |
setGravity(gravity: Int)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. |
Unit |
@RequiresApi(value = Build.VERSION_CODES.LOLLIPOP)Set the corner radius of curvature |
Unit |
@RequiresApi(value = Build.VERSION_CODES.LOLLIPOP)Set the corner radius of curvature as a fraction of the smaller side. |
Unit |
setScaleFromTextSize(size: Float)if set the font is rendered to polygons at this size and then scaled to the size set by textSize. |
Unit |
setText(text: CharSequence!)set text |
Unit |
setTextBackgroundPanX(pan: Float)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 |
Unit |
setTextBackgroundPanY(pan: Float)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 |
Unit |
setTextBackgroundRotate(rotation: Float)sets the rotation angle of the image in degrees |
Unit |
setTextBackgroundZoom(zoom: Float)sets the zoom where 1 scales the image just enough to fill the view |
Unit |
setTextFillColor(color: Int)Set the color of the text. |
Unit |
setTextOutlineColor(color: Int)Sets the color of the text outline. |
Unit |
setTextOutlineThickness(width: Float)Set outline thickness |
Unit |
setTextPanX(textPanX: Float)Pan the Texture in the text in the x axis. |
Unit |
setTextPanY(textPanY: Float)Pan the Texture in the text in the y axis. |
Unit |
setTextSize(size: Float)set text size |
Unit |
setTextureHeight(mTextureHeight: Float)set the height of the texture. |
Unit |
setTextureWidth(mTextureWidth: Float)set the width of the texture. |
Unit |
setTypeface(tf: Typeface!)set the typeface |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
Public functions
getRound
fun getRound(): Float
Get the corner radius of curvature NaN = RoundPercent in effect.
| Returns | |
|---|---|
Float |
Radius of curvature |
getRoundPercent
fun getRoundPercent(): Float
Get the fractional corner radius of curvature.
| Returns | |
|---|---|
Float |
Fractional radius of curvature with respect to smallest size |
getScaleFromTextSize
fun getScaleFromTextSize(): Float
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
fun getTextBackgroundPanX(): 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
| Returns | |
|---|---|
Float |
the pan in X. Where 0 is centered = Float. NaN if not set |
getTextBackgroundPanY
fun getTextBackgroundPanY(): 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
| Returns | |
|---|---|
Float |
pan in y. Where 0 is centered NaN if not set |
getTextBackgroundRotate
fun getTextBackgroundRotate(): Float
gets the rotation
| Returns | |
|---|---|
Float |
the rotation in degrees |
getTextBackgroundZoom
fun getTextBackgroundZoom(): Float
gets the zoom where 1 scales the image just enough to fill the view
| Returns | |
|---|---|
Float |
the zoom factor |
getTextPanX
fun getTextPanX(): Float
Pan the Texture in the text in the x axis.
| Returns | |
|---|---|
Float |
pan of the Text -1 = left 0 = center +1 = right |
getTextPanY
fun getTextPanY(): Float
Pan the Texture in the text in the y axis.
| Returns | |
|---|---|
Float |
the pan value 0 being centered in the center of screen. |
getTextureHeight
fun getTextureHeight(): Float
Pan the Texture in the text in the y axis.
| Returns | |
|---|---|
Float |
pan of the Text -1 = top 0 = center +1 = bottom |
getTextureWidth
fun getTextureWidth(): Float
get the width of the texture. Setting Float.NaN is the default Use the view size.
| Returns | |
|---|---|
Float |
the width of the texture |
getTypeface
fun getTypeface(): Typeface!
| Returns | |
|---|---|
Typeface! |
the current typeface and style in which the text is being displayed. |
| See also | |
|---|---|
setTypeface |
layout
fun layout(l: Float, t: Float, r: Float, b: Float): Unit
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
fun setGravity(gravity: Int): Unit
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)
fun setRound(round: Float): Unit
Set the corner radius of curvature
| Parameters | |
|---|---|
round: Float |
the radius of curvature NaN = default meaning roundPercent in effect |
setRoundPercent
@RequiresApi(value = Build.VERSION_CODES.LOLLIPOP)
fun setRoundPercent(round: Float): Unit
Set the corner radius of curvature as a fraction of the smaller side. For squares 1 will result in a circle
| Parameters | |
|---|---|
round: Float |
the radius of curvature as a fraction of the smaller width |
setScaleFromTextSize
fun setScaleFromTextSize(size: Float): Unit
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 | |
|---|---|
size: Float |
the size to pre render the font or NaN if not used. |
setText
fun setText(text: CharSequence!): Unit
set text
| Parameters | |
|---|---|
text: CharSequence! |
setTextBackgroundPanX
fun setTextBackgroundPanX(pan: Float): Unit
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 | |
|---|---|
pan: Float |
sets the pan in X. Where 0 is centered |
setTextBackgroundPanY
fun setTextBackgroundPanY(pan: Float): Unit
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 | |
|---|---|
pan: Float |
sets the pan in X. Where 0 is centered |
setTextBackgroundRotate
fun setTextBackgroundRotate(rotation: Float): Unit
sets the rotation angle of the image in degrees
| Parameters | |
|---|---|
rotation: Float |
angle in degrees |
setTextBackgroundZoom
fun setTextBackgroundZoom(zoom: Float): Unit
sets the zoom where 1 scales the image just enough to fill the view
| Parameters | |
|---|---|
zoom: Float |
the zoom factor |
setTextFillColor
fun setTextFillColor(color: Int): Unit
Set the color of the text.
| Parameters | |
|---|---|
color: Int |
the color of the text |
setTextOutlineColor
fun setTextOutlineColor(color: Int): Unit
Sets the color of the text outline.
| Parameters | |
|---|---|
color: Int |
the color of the outline of the text |
setTextOutlineThickness
fun setTextOutlineThickness(width: Float): Unit
Set outline thickness
| Parameters | |
|---|---|
width: Float |
setTextPanX
fun setTextPanX(textPanX: Float): Unit
Pan the Texture in the text in the x axis.
| Parameters | |
|---|---|
textPanX: Float |
pan of the Text -1 = left 0 = center +1 = right |
setTextPanY
fun setTextPanY(textPanY: Float): Unit
Pan the Texture in the text in the y axis.
| Parameters | |
|---|---|
textPanY: Float |
pan of the Text -1 = top 0 = center +1 = bottom |
setTextSize
fun setTextSize(size: Float): Unit
set text size
| Parameters | |
|---|---|
size: Float |
the size of the text |
| See also | |
|---|---|
setTextSize |
setTextureHeight
fun setTextureHeight(mTextureHeight: Float): Unit
set the height of the texture. Setting Float.NaN is the default Use the view size.
| Parameters | |
|---|---|
mTextureHeight: Float |
the height of the texture |
setTextureWidth
fun setTextureWidth(mTextureWidth: Float): Unit
set the width of the texture. Setting Float.NaN is the default Use the view size
| Parameters | |
|---|---|
mTextureWidth: Float |
set the width of the texture Float.NaN clears setting |
setTypeface
fun setTypeface(tf: Typeface!): Unit
set the typeface
| Parameters | |
|---|---|
tf: Typeface! |