-
Notifications
You must be signed in to change notification settings - Fork 468
5、代码生成Drawable的DrawableCreator工具类
javaKepp edited this page May 14, 2019
·
1 revision
所有的属性都提供了set方法去通过代码设置,具体见DrawableCreator.Build 使用方法如下:
//设置button圆角背景
Drawable drawable = new DrawableCreator.Builder().setCornersRadius(dip2px(20))
.setGradientAngle(0).setGradientColor(Color.parseColor("#63B8FF"), Color.parseColor("#4F94CD")).build();
btn.setBackground(drawable);
//文字点击变色
tvTest1.setClickable(true);//由于Android源码的原因,必须调用,否则不生效
ColorStateList colors = new DrawableCreator.Builder().setPressedTextColor(Color.RED).setUnPressedTextColor(Color.BLUE).buildTextColor();
tvTest1.setTextColor(colors);