public class SuperButton
extends AppCompatButton
| Modifier and Type | Field and Description |
|---|---|
static int |
BL_TR |
static int |
BOTTOM_TOP |
static int |
BR_TL |
static int |
LEFT_RIGHT |
static int |
LINE |
static int |
OVAL |
static int |
RECTANGLE |
static int |
RIGHT_LEFT |
static int |
RING |
static int |
TEXT_GRAVITY_BOTTOM |
static int |
TEXT_GRAVITY_CENTER |
static int |
TEXT_GRAVITY_LEFT |
static int |
TEXT_GRAVITY_RIGHT |
static int |
TEXT_GRAVITY_TOP |
static int |
TL_BR |
static int |
TOP_BOTTOM |
static int |
TR_BL |
| Constructor and Description |
|---|
SuperButton(android.content.Context context) |
SuperButton(android.content.Context context,
android.util.AttributeSet attrs) |
SuperButton(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr) |
| Modifier and Type | Method and Description |
|---|---|
android.graphics.drawable.GradientDrawable |
getDrawable(int state)
设置GradientDrawable
|
android.graphics.drawable.StateListDrawable |
getSelector()
获取设置之后的Selector
|
void |
setChangeAlphaWhenDisable(boolean changeAlphaWhenDisable)
设置是否要在 disabled 时改变透明度
|
void |
setChangeAlphaWhenPress(boolean changeAlphaWhenPress)
设置是否要在 press 时改变透明度
|
void |
setEnabled(boolean enabled) |
void |
setPressed(boolean pressed) |
SuperButton |
setShapeCornersBottomLeftRadius(float radius)
设置左下圆角半径
|
SuperButton |
setShapeCornersBottomRightRadius(float radius)
设置右下圆角半径
|
SuperButton |
setShapeCornersRadius(float radius)
设置圆角半径
|
SuperButton |
setShapeCornersTopLeftRadius(float radius)
设置左上圆角半径
|
SuperButton |
setShapeCornersTopRightRadius(float radius)
设置右上圆角半径
|
SuperButton |
setShapeGradientCenterColor(int gradientCenterColor)
设置渐变中间的颜色
|
SuperButton |
setShapeGradientCenterX(int gradientCenterX)
设置渐变中心X
|
SuperButton |
setShapeGradientCenterY(int gradientCenterY)
设置渐变中心Y
|
SuperButton |
setShapeGradientEndColor(int gradientEndColor)
设置渐变结束的颜色
|
SuperButton |
setShapeGradientGradientRadius(int gradientGradientRadius)
设置渐变半径
|
SuperButton |
setShapeGradientOrientation(int gradientOrientation)
设置背景渐变方式
|
SuperButton |
setShapeGradientStartColor(int gradientStartColor)
设置渐变开始的颜色
|
SuperButton |
setShapeGradientType(int gradientType)
设置渐变类型
|
SuperButton |
setShapeGradientUseLevel(boolean gradientUseLevel)
设置是否使用UseLevel
|
SuperButton |
setShapeSelectorDisableColor(int color)
设置不可点击的颜色
|
SuperButton |
setShapeSelectorNormalColor(int color)
设置正常的颜色
|
SuperButton |
setShapeSelectorPressedColor(int color)
设置按下的颜色
|
SuperButton |
setShapeSizeHeight(int sizeHeight)
设置shape的高度
|
SuperButton |
setShapeSizeWidth(int sizeWidth)
设置shape的宽度
|
SuperButton |
setShapeSolidColor(int color)
设置填充的颜色
|
SuperButton |
setShapeStrokeColor(int strokeColor)
设置边框颜色
|
SuperButton |
setShapeStrokeDashGap(float strokeDashGap)
设置边框虚线间隙
|
SuperButton |
setShapeStrokeDashWidth(float strokeDashWidth)
设置边框虚线宽度
|
SuperButton |
setShapeStrokeWidth(int strokeWidth)
设置边框宽度
|
SuperButton |
setShapeType(int type)
设置Shape类型
|
SuperButton |
setShapeUseSelector(boolean useSelector)
是否使用selector
|
SuperButton |
setTextGravity(int gravity)
设置文字对其方式
|
void |
setUseShape()
使用shape
所有与shape相关的属性设置之后调用此方法才生效
|
public static final int RECTANGLE
public static final int OVAL
public static final int LINE
public static final int RING
public static final int TOP_BOTTOM
public static final int TR_BL
public static final int RIGHT_LEFT
public static final int BR_TL
public static final int BOTTOM_TOP
public static final int BL_TR
public static final int LEFT_RIGHT
public static final int TL_BR
public static final int TEXT_GRAVITY_CENTER
public static final int TEXT_GRAVITY_LEFT
public static final int TEXT_GRAVITY_RIGHT
public static final int TEXT_GRAVITY_TOP
public static final int TEXT_GRAVITY_BOTTOM
public SuperButton(android.content.Context context)
public SuperButton(android.content.Context context,
android.util.AttributeSet attrs)
public SuperButton(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr)
public android.graphics.drawable.StateListDrawable getSelector()
public android.graphics.drawable.GradientDrawable getDrawable(int state)
state - 按钮状态public SuperButton setShapeType(int type)
type - 类型public SuperButton setTextGravity(int gravity)
gravity - 对齐方式public SuperButton setShapeSelectorPressedColor(int color)
color - 颜色public SuperButton setShapeSelectorNormalColor(int color)
color - 颜色public SuperButton setShapeSelectorDisableColor(int color)
color - 颜色public SuperButton setShapeSolidColor(int color)
color - 颜色public SuperButton setShapeStrokeWidth(int strokeWidth)
strokeWidth - 边框宽度值public SuperButton setShapeStrokeColor(int strokeColor)
strokeColor - 边框颜色public SuperButton setShapeStrokeDashWidth(float strokeDashWidth)
strokeDashWidth - 边框虚线宽度public SuperButton setShapeStrokeDashGap(float strokeDashGap)
strokeDashGap - 边框虚线间隙值public SuperButton setShapeCornersRadius(float radius)
radius - 半径public SuperButton setShapeCornersTopLeftRadius(float radius)
radius - 半径public SuperButton setShapeCornersTopRightRadius(float radius)
radius - 半径public SuperButton setShapeCornersBottomLeftRadius(float radius)
radius - 半径public SuperButton setShapeCornersBottomRightRadius(float radius)
radius - 半径public SuperButton setShapeSizeWidth(int sizeWidth)
sizeWidth - 宽public SuperButton setShapeSizeHeight(int sizeHeight)
sizeHeight - 高public SuperButton setShapeGradientOrientation(int gradientOrientation)
gradientOrientation - 渐变类型public SuperButton setShapeGradientCenterX(int gradientCenterX)
gradientCenterX - 中心xpublic SuperButton setShapeGradientCenterY(int gradientCenterY)
gradientCenterY - 中心ypublic SuperButton setShapeGradientGradientRadius(int gradientGradientRadius)
gradientGradientRadius - 渐变半径public SuperButton setShapeGradientStartColor(int gradientStartColor)
gradientStartColor - 开始颜色public SuperButton setShapeGradientCenterColor(int gradientCenterColor)
gradientCenterColor - 中间颜色public SuperButton setShapeGradientEndColor(int gradientEndColor)
gradientEndColor - 结束颜色public SuperButton setShapeGradientType(int gradientType)
gradientType - 类型public SuperButton setShapeGradientUseLevel(boolean gradientUseLevel)
gradientUseLevel - true or falsepublic SuperButton setShapeUseSelector(boolean useSelector)
useSelector - true or falsepublic void setUseShape()
public void setPressed(boolean pressed)
public void setEnabled(boolean enabled)
public void setChangeAlphaWhenPress(boolean changeAlphaWhenPress)
changeAlphaWhenPress - 是否要在 press 时改变透明度public void setChangeAlphaWhenDisable(boolean changeAlphaWhenDisable)
changeAlphaWhenDisable - 是否要在 disabled 时改变透明度