public class SuperTextView
extends TextView
限定符和类型 | 类和说明 |
---|---|
static class |
SuperTextView.Adjuster
Adjuster被设计用来在SuperTextView的绘制过程中插入一些操作。
|
static class |
SuperTextView.DrawableMode
状态图的显示模式。
|
static class |
SuperTextView.ShaderMode
SuperTextView的渐变模式。
|
构造器和说明 |
---|
SuperTextView(Context context)
简单的构造函数
|
SuperTextView(Context context,
AttributeSet attrs)
inflate Xml布局文件时会被调用
|
SuperTextView(Context context,
AttributeSet attrs,
int defStyleAttr)
略
|
SuperTextView(Context context,
AttributeSet attrs,
int defStyleAttr,
int defStyleRes)
略
|
限定符和类型 | 方法和说明 |
---|---|
SuperTextView |
addAdjuster(SuperTextView.Adjuster adjuster)
添加一个Adjuster。
|
SuperTextView.Adjuster |
getAdjuster()
获取最后一个
SuperTextView.Adjuster |
SuperTextView.Adjuster |
getAdjuster(int index)
获得index对应的
SuperTextView.Adjuster 。 |
java.util.List<SuperTextView.Adjuster> |
getAdjusterList()
获得SuperTextView中的所有Adjuster,如果没有返回null
|
float |
getCorner()
获取SuperTextView的圆角大小
|
float[] |
getCorners()
获取SuperTextView的详细圆角信息,共4个圆角,每个圆角包含两个值。
|
Drawable |
getDrawable()
获取状态图,当状态图通过
setDrawableAsBackground(boolean) 设置为背景时,获取的就是背景图了。 |
Drawable |
getDrawable2()
获取状态图2号。
|
float |
getDrawable2Height()
获取状态图2的高度
|
float |
getDrawable2PaddingLeft()
获取状态图2相对于控件左边的边距。
|
float |
getDrawable2PaddingTop()
获取状态图2相对于控件上边的边距。
|
float |
getDrawable2Rotate()
获得第二个状态图的旋转角度。
|
int |
getDrawable2Tint()
获得第二个状态图的混合颜色。
|
float |
getDrawable2Width()
获取状态图2的宽度。
|
float |
getDrawableHeight()
获取状态图的高度
|
float |
getDrawablePaddingLeft()
获取状态图相对于控件左边的边距。
|
float |
getDrawablePaddingTop()
获取状态图相对于控件上边的边距。
|
float |
getDrawableRotate()
获得第一个状态图的旋转角度。
|
int |
getDrawableTint()
获得第一个状态图的混合颜色。
|
float |
getDrawableWidth()
获取状态图的宽度。
|
int |
getFrameRate()
获取当前SuperTextView在播放
SuperTextView.Adjuster 时的帧率。 |
int |
getPressBgColor()
获得当前按压背景色。
|
int |
getPressTextColor()
获得当前按压文字颜色色。
|
int |
getShaderEndColor()
获取渐变色的结束颜色。
|
SuperTextView.ShaderMode |
getShaderMode()
获取渐变色模式。
|
int |
getShaderStartColor()
获取渐变色的起始颜色。
|
int |
getSolid()
获取填充颜色
|
SuperTextView.DrawableMode |
getStateDrawable2Mode()
获取状态图2的显示模式。
|
SuperTextView.DrawableMode |
getStateDrawableMode()
获取状态图的显示模式。
|
int |
getStrokeColor()
获取边框颜色
|
float |
getStrokeWidth()
获取控件边框宽度
|
int |
getTextFillColor()
获取文字的填充颜色,在开启文字描边时
setTextStroke(boolean) 默认为BLACK。 |
int |
getTextShaderEndColor()
获取文字渐变色的结束颜色。
|
SuperTextView.ShaderMode |
getTextShaderMode()
获取文字渐变色模式。
|
int |
getTextShaderStartColor()
获取文字渐变色的起始颜色。
|
int |
getTextStrokeColor()
获取文字描边的颜色
|
float |
getTextStrokeWidth()
获取文字描边的宽度
|
boolean |
isAutoAdjust()
检查是否开启
SuperTextView.Adjuster 功能。 |
boolean |
isDrawableAsBackground()
检查当前状态图是否被作为SuperTextView的背景图。
|
boolean |
isLeftBottomCornerEnable()
检查左下角是否设置成了圆角。
|
boolean |
isLeftTopCornerEnable()
检查左上角是否设置成了圆角。
|
boolean |
isRightBottomCornerEnable()
检查右下角是否设置成了圆角。
|
boolean |
isRightTopCornerEnable()
检查右上角是否设置成了圆角。
|
boolean |
isShaderEnable()
检查是否启用了渐变功能。
|
boolean |
isShowState()
检查是否显示状态图
|
boolean |
isShowState2()
检查是否显示状态图2。
|
boolean |
isTextShaderEnable()
检查是否启用了文字渐变功能。
|
boolean |
isTextStroke()
检查是否开启了文字描边
|
boolean |
onTouchEvent(MotionEvent event) |
SuperTextView.Adjuster |
removeAdjuster(int index)
移除指定位置的Adjuster。
|
int |
removeAdjuster(SuperTextView.Adjuster adjuster)
移除指定的Adjuster,如果包含的话。
|
SuperTextView |
setAutoAdjust(boolean autoAdjust)
设置是否开启
SuperTextView.Adjuster 功能。 |
SuperTextView |
setCorner(float corner)
设置圆角大小
|
SuperTextView |
setDrawable(Drawable drawable)
设置状态图。
|
SuperTextView |
setDrawable2(Drawable drawable)
设置状态图2。
|
SuperTextView |
setDrawable2Height(float drawableHeight)
设置状态图2高度。
|
SuperTextView |
setDrawable2PaddingLeft(float drawablePaddingLeft)
设置状态图2相对于控件左边的边距。
|
SuperTextView |
setDrawable2PaddingTop(float drawablePaddingTop)
设置状态图2相对于控件上边的边距。
|
SuperTextView |
setDrawable2Rotate(float rotate)
设置第二个状态图的旋转角度。
|
SuperTextView |
setDrawable2Tint(int tintColor)
设置第二个状态图的混合颜色。
|
SuperTextView |
setDrawable2Width(float drawableWidth)
设置状态图2宽度。
|
SuperTextView |
setDrawableAsBackground(boolean drawableAsBackground)
设置是否将状态图作为SuperTextView的背景图。
|
SuperTextView |
setDrawableHeight(float drawableHeight)
设置状态图高度。
|
SuperTextView |
setDrawablePaddingLeft(float drawablePaddingLeft)
设置状态图相对于控件左边的边距。
|
SuperTextView |
setDrawablePaddingTop(float drawablePaddingTop)
设置状态图相对于控件上边的边距。
|
SuperTextView |
setDrawableRotate(float rotate)
设置第一个状态图的旋转角度。
|
SuperTextView |
setDrawableTint(int tintColor)
设置第一个状态图的混合颜色。
|
SuperTextView |
setDrawableWidth(float drawableWidth)
设置状态图宽度。
|
SuperTextView |
setFrameRate(int frameRate)
设置帧率,即每秒帧数。
|
SuperTextView |
setLeftBottomCornerEnable(boolean leftBottomCornerEnable)
设置左下角是否为圆角,可以单独控制SuperTextView的每一个圆角。
|
SuperTextView |
setLeftTopCornerEnable(boolean leftTopCornerEnable)
设置左上角是否为圆角,可以单独控制SuperTextView的每一个圆角。
|
SuperTextView |
setPressBgColor(int pressBgColor)
获得当前按压背景色。
|
SuperTextView |
setPressTextColor(int pressTextColor)
获得当前按压文字色。
|
SuperTextView |
setRightBottomCornerEnable(boolean rightBottomCornerEnable)
设置右下角是否为圆角,可以单独控制SuperTextView的每一个圆角。
|
SuperTextView |
setRightTopCornerEnable(boolean rightTopCornerEnable)
设置右上角是否为圆角,可以单独控制SuperTextView的每一个圆角。
|
SuperTextView |
setShaderEnable(boolean shaderEnable)
设置是否启用渐变色功能。
|
SuperTextView |
setShaderEndColor(int shaderEndColor)
设置渐变结束色。
|
SuperTextView |
setShaderMode(SuperTextView.ShaderMode shaderMode)
设置渐变模式。
|
SuperTextView |
setShaderStartColor(int shaderStartColor)
设置渐变起始色。
|
SuperTextView |
setShowState(boolean showState)
设置是否显示状态图。
|
SuperTextView |
setShowState2(boolean showState)
设置是否显示状态图2
|
SuperTextView |
setSolid(int solid)
设置填充颜色
|
SuperTextView |
setStateDrawable2Mode(SuperTextView.DrawableMode stateDrawableMode)
设置状态图2显示模式。
|
SuperTextView |
setStateDrawableMode(SuperTextView.DrawableMode stateDrawableMode)
设置状态图显示模式。
|
SuperTextView |
setStrokeColor(int strokeColor)
设置边框颜色
|
SuperTextView |
setStrokeWidth(float strokeWidth)
设置控件边框宽度
|
SuperTextView |
setTextFillColor(int textFillColor)
设置文字的填充颜色,需要开启文字描边
setTextStroke(boolean) 才能生效。 |
SuperTextView |
setTextShaderEnable(boolean shaderEnable)
设置是否启用文字渐变色功能。
|
SuperTextView |
setTextShaderEndColor(int shaderEndColor)
设置文字渐变结束色。
|
SuperTextView |
setTextShaderMode(SuperTextView.ShaderMode shaderMode)
设置文字渐变模式。
|
SuperTextView |
setTextShaderStartColor(int shaderStartColor)
设置文字渐变起始色。
|
SuperTextView |
setTextStroke(boolean textStroke)
设置是否开启文字描边。
|
SuperTextView |
setTextStrokeColor(int textStrokeColor)
设置文字描边的颜色
|
SuperTextView |
setTextStrokeWidth(float textStrokeWidth)
设置文字描边的宽度,需要开启文字描边
setTextStroke(boolean) 才能生效。 |
SuperTextView |
setUrlImage(java.lang.String url)
将一个网络图片作为SuperTextView的StateDrawable,调用这个方法StateDrawable将会被设置为背景模式。
|
SuperTextView |
setUrlImage(java.lang.String url,
boolean asBackground)
将一个网络图片作为SuperTextView的StateDrawable。
|
void |
startAnim()
启动动画。
|
void |
stopAnim()
停止动画。
|
public static final int NO_COLOR
public static final float NO_ROTATE
public SuperTextView(Context context)
context
- View运行的Context环境public SuperTextView(Context context, AttributeSet attrs)
context
- View运行的Context环境attrs
- View在xml布局文件中配置的属性集合对象public SuperTextView(Context context, AttributeSet attrs, int defStyleAttr)
context
- attrs
- defStyleAttr
- public SuperTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
context
- attrs
- defStyleAttr
- defStyleRes
- public float[] getCorners()
getCorners(float)
.public float getCorner()
public SuperTextView setCorner(float corner)
corner
- 圆角大小,默认值为0。会触发一次重绘。public int getSolid()
public SuperTextView setSolid(int solid)
solid
- 控件填充颜色, 默认为Color#TRANSPARENT
。会触发一次重绘。public float getStrokeWidth()
public SuperTextView setStrokeWidth(float strokeWidth)
strokeWidth
- 描边宽度。会触发一次重绘。public int getStrokeColor()
Color#BLACK
。public SuperTextView setStrokeColor(int strokeColor)
strokeColor
- 描边颜色。默认为Color#BLACK
。会触发一次重绘。public SuperTextView.Adjuster getAdjuster()
SuperTextView.Adjuster
SuperTextView.Adjuster
,如果存在的话。public SuperTextView.Adjuster getAdjuster(int index)
SuperTextView.Adjuster
。index
- 期望获得的Adjuster的index。public java.util.List<SuperTextView.Adjuster> getAdjusterList()
public SuperTextView addAdjuster(SuperTextView.Adjuster adjuster)
adjuster
- SuperTextView.Adjuster
。会触发一次重绘。public SuperTextView.Adjuster removeAdjuster(int index)
index
- 期望移除的Adjuster的位置。public int removeAdjuster(SuperTextView.Adjuster adjuster)
adjuster
- 需要被移除的Adjusterpublic boolean isTextStroke()
public SuperTextView setTextStroke(boolean textStroke)
setTextFillColor(int)
设置。textStroke
- true表示开启文字描边。默认为false。会触发一次重绘。public int getTextStrokeColor()
public SuperTextView setTextStrokeColor(int textStrokeColor)
textStrokeColor
- 设置文字描边的颜色。默认为Color#BLACK
。会触发一次重绘。public int getTextFillColor()
setTextStroke(boolean)
默认为BLACK。public SuperTextView setTextFillColor(int textFillColor)
setTextStroke(boolean)
才能生效。默认为BLACK。textFillColor
- 设置文字填充颜色。默认为Color#BLACK
。会触发一次重绘。public float getTextStrokeWidth()
public SuperTextView setTextStrokeWidth(float textStrokeWidth)
setTextStroke(boolean)
才能生效。textStrokeWidth
- 设置文字描边宽度。会触发一次重绘。public boolean isAutoAdjust()
SuperTextView.Adjuster
功能。public SuperTextView setAutoAdjust(boolean autoAdjust)
SuperTextView.Adjuster
功能。autoAdjust
- true开启Adjuster功能。反之,关闭。会触发一次重绘。public boolean isLeftTopCornerEnable()
public SuperTextView setLeftTopCornerEnable(boolean leftTopCornerEnable)
leftTopCornerEnable
- true左上角圆角化。会触发一次重绘。public boolean isRightTopCornerEnable()
public SuperTextView setRightTopCornerEnable(boolean rightTopCornerEnable)
rightTopCornerEnable
- true右上角圆角化。会触发一次重绘。public boolean isLeftBottomCornerEnable()
public SuperTextView setLeftBottomCornerEnable(boolean leftBottomCornerEnable)
leftBottomCornerEnable
- true左下角圆角化。会触发一次重绘。public boolean isRightBottomCornerEnable()
public SuperTextView setRightBottomCornerEnable(boolean rightBottomCornerEnable)
rightBottomCornerEnable
- true右下角圆角化。会触发一次重绘。public Drawable getDrawable()
setDrawableAsBackground(boolean)
设置为背景时,获取的就是背景图了。public Drawable getDrawable2()
public SuperTextView setDrawable(Drawable drawable)
setShowState(boolean)
才能显示。会触发一次重绘。
当通过 setDrawableAsBackground(boolean)
将状态图设置为背景后,将会被作为SuperTextView的背景图。
通过 isDrawableAsBackground()
来检查状态图是否被设置成了背景。drawable
- 状态图。public SuperTextView setDrawable2(Drawable drawable)
setShowState2(boolean)
才能显示。会触发一次重绘。drawable
- 状态图public boolean isShowState()
public SuperTextView setShowState(boolean showState)
showState
- true,表示显示状态图。反之,不显示。会触发一次重绘。public boolean isDrawableAsBackground()
public SuperTextView setDrawableAsBackground(boolean drawableAsBackground)
setUrlImage(String)
和 setUrlImage(String, boolean)
可以使得SuperTextView能够自动下载网络图片,然后进行展示。drawableAsBackground
- true,表示将Drawable作为背景图,其余所有对drawable的设置都会失效,直到该项为false。public boolean isShowState2()
public SuperTextView setShowState2(boolean showState)
showState
- true,表示显示状态图2。反之,不显示。会触发一次重绘。public SuperTextView.DrawableMode getStateDrawableMode()
SuperTextView.DrawableMode
中查看所有支持的模式。SuperTextView.DrawableMode
public SuperTextView.DrawableMode getStateDrawable2Mode()
SuperTextView.DrawableMode
中查看所有支持的模式。SuperTextView.DrawableMode
public SuperTextView setStateDrawableMode(SuperTextView.DrawableMode stateDrawableMode)
SuperTextView.DrawableMode.CENTER
。会触发一次重绘。
在 SuperTextView.DrawableMode
中查看所有支持的模式。stateDrawableMode
- 状态图显示模式public SuperTextView setStateDrawable2Mode(SuperTextView.DrawableMode stateDrawableMode)
SuperTextView.DrawableMode.CENTER
。会触发一次重绘。
在 SuperTextView.DrawableMode
中查看所有支持的模式。stateDrawableMode
- 状态图2显示模式public float getDrawableWidth()
public float getDrawable2Width()
public SuperTextView setDrawableWidth(float drawableWidth)
drawableWidth
- 状态图宽度public SuperTextView setDrawable2Width(float drawableWidth)
drawableWidth
- 状态图2宽度public float getDrawableHeight()
public float getDrawable2Height()
public SuperTextView setDrawableHeight(float drawableHeight)
drawableHeight
- 状态图高度public SuperTextView setDrawable2Height(float drawableHeight)
drawableHeight
- 状态图2高度public float getDrawablePaddingLeft()
public float getDrawable2PaddingLeft()
public SuperTextView setDrawablePaddingLeft(float drawablePaddingLeft)
drawablePaddingLeft
- 状态图左边距。public SuperTextView setDrawable2PaddingLeft(float drawablePaddingLeft)
drawablePaddingLeft
- 状态图左边距。public float getDrawablePaddingTop()
public float getDrawable2PaddingTop()
public SuperTextView setDrawablePaddingTop(float drawablePaddingTop)
drawablePaddingTop
- 状态图上边距。public SuperTextView setDrawable2PaddingTop(float drawablePaddingTop)
drawablePaddingTop
- 状态图2上边距。public SuperTextView setDrawableTint(int tintColor)
NO_COLOR
.tintColor
- 目标混合颜色public int getDrawableTint()
NO_COLOR
public SuperTextView setDrawable2Tint(int tintColor)
NO_COLOR
.tintColor
- 目标混合颜色public int getDrawable2Tint()
NO_COLOR
public SuperTextView setDrawableRotate(float rotate)
NO_ROTATE
.rotate
- 需要旋转的角度public float getDrawableRotate()
NO_ROTATE
public SuperTextView setDrawable2Rotate(float rotate)
NO_ROTATE
.rotate
- 需要旋转的角度public float getDrawable2Rotate()
NO_ROTATE
public int getShaderStartColor()
public SuperTextView setShaderStartColor(int shaderStartColor)
setShaderEnable(boolean)
后才能生效。会触发一次重绘。shaderStartColor
- 渐变起始色public int getShaderEndColor()
public SuperTextView setShaderEndColor(int shaderEndColor)
setShaderEnable(boolean)
后才能生效。会触发一次重绘。shaderEndColor
- 渐变结束色public SuperTextView.ShaderMode getShaderMode()
SuperTextView.ShaderMode
中可以查看所有支持的模式。
需要调用setShaderEnable(boolean)
后才能生效。public SuperTextView setShaderMode(SuperTextView.ShaderMode shaderMode)
SuperTextView.ShaderMode
中可以查看所有支持的模式。
需要调用setShaderEnable(boolean)
后才能生效。shaderMode
- 渐变模式public boolean isShaderEnable()
public SuperTextView setShaderEnable(boolean shaderEnable)
shaderEnable
- true启用渐变功能。反之,停用。public int getTextShaderStartColor()
public SuperTextView setTextShaderStartColor(int shaderStartColor)
setTextShaderEnable(boolean)
后才能生效。会触发一次重绘。shaderStartColor
- 文字渐变起始色public int getTextShaderEndColor()
public SuperTextView setTextShaderEndColor(int shaderEndColor)
setShaderEnable(boolean)
后才能生效。会触发一次重绘。shaderEndColor
- 文字渐变结束色public SuperTextView.ShaderMode getTextShaderMode()
SuperTextView.ShaderMode
中可以查看所有支持的模式。
需要调用setTextShaderEnable(boolean)
后才能生效。public SuperTextView setTextShaderMode(SuperTextView.ShaderMode shaderMode)
SuperTextView.ShaderMode
中可以查看所有支持的模式。
需要调用setTextShaderEnable(boolean)
后才能生效。shaderMode
- 文字渐变模式public boolean isTextShaderEnable()
public SuperTextView setTextShaderEnable(boolean shaderEnable)
shaderEnable
- true启用文字渐变功能。反之,停用。public int getPressBgColor()
public SuperTextView setPressBgColor(int pressBgColor)
pressBgColor
- 按压背景色public int getPressTextColor()
public SuperTextView setPressTextColor(int pressTextColor)
pressTextColor
- 按压时文字颜色public int getFrameRate()
SuperTextView.Adjuster
时的帧率。默认为60fpspublic SuperTextView setFrameRate(int frameRate)
frameRate
- 帧率public SuperTextView setUrlImage(java.lang.String url, boolean asBackground)
Engine
,
然后通过ImageEngine.install(Engine)
为SuperTextView的ImageEngine安装一个全局引擎,开发者可以在
Application#onCreate()
中进行配置(需要注意任何时候新安装的引擎总会替换掉原本的引擎)。
在未设置引擎的情况下,SuperTextView仍然会通过内置的一个十分简易引擎去下载图片。url
- 网络图片地址asBackground
- 是否将下载的图片作为Background。
- false表示下载好的图片将作为SuperTextView的StateDrawable
- true表示将下载好的图片作为背景,效果和setDrawableAsBackground(boolean)
是一样的。public SuperTextView setUrlImage(java.lang.String url)
Engine
,
然后通过ImageEngine.install(Engine)
为SuperTextView的ImageEngine安装一个全局引擎,开发者可以在
Application#onCreate()
中进行配置(需要注意任何时候新安装的引擎总会替换掉原本的引擎)。
在未设置引擎的情况下,SuperTextView仍然会通过内置的一个十分简易引擎去下载图片。url
- 网络图片地址public void startAnim()
setAutoAdjust(boolean)
为true才能看到。public void stopAnim()
public boolean onTouchEvent(MotionEvent event)