自定义Drawable
程序员文章站
2024-03-24 08:37:58
...
## 重写draw ##
@Override
public void draw(Canvas canvas) {
int height = canvas.getHeight();
int width = canvas.getWidth();
//设置渐变色
LinearGradient linearGradient = new LinearGradient(width / 2, 0, width / 2, canvas.getHeight(), mBgColor, 0xffffffff, Shader.TileMode.MIRROR);
mBgPaint.setShader(linearGradient);
canvas.drawRect(new RectF(0, 0, canvas.getWidth(), canvas.getHeight()), mBgPaint);
int radius = DisplayUtil.dip2px(mContext, 38);
paint.setColor(0x4dffffff);
canvas.drawCircle(0, height / 5 * 2 - 28, radius, paint);
radius = DisplayUtil.dip2px(mContext, 20);
paint.setColor(0x1affffff);
canvas.drawCircle(width / 3, 0, radius, paint);
radius = DisplayUtil.dip2px(mContext, 18);
paint.setColor(0x4dffffff);
canvas.drawCircle(width / 5 * 3, height / 4, radius, paint);
radius = DisplayUtil.dip2px(mContext, 68);
paint.setColor(0x33ffffff);
canvas.drawCircle(width , 0, radius, paint);
}
推荐阅读
-
android drawable.setAlpha设置无效的解决办法
-
自定义Drawable
-
Android:解决RadioGroup中RadioButton的图片自定义及每项间隔距离一样 博客分类: android android
-
代码创建可绘制对象 Drawable
-
Android动画篇——Drawable Animation(帧动画)
-
Drawable Animation (Drawable动画)
-
controller如何拿到自定义view的点击事件?
-
获取Drawable目录下的资源
-
使用hstore实现postgresql自定义聚合函数 博客分类: postgresql postgresqlhstore聚合函数
-
自定义javascript事件 javascript