辉光动态生成线有效
问题描述:
我想提请像这样
问题光晕效果行 - 我必须生成该行计划在依赖用户的交互(线的形式将在onTouchEvent
产生 - ACTION_MOVE
)。辉光动态生成线有效
我可以产生这种效果没有XML文件或绘制premaid位图?
答
我模仿这种方式这样的效果:
- 与
BlurMaskFilter
绘制线; - 在其上画法线。
我使用Path类生成行并保存坐标为MOVE_ACTION
的事件,以仅生成我需要的部分路径。
创建2 Paint()
S:
_paintSimple = new Paint();
_paintSimple.setAntiAlias(true);
_paintSimple.setDither(true);
_paintSimple.setColor(Color.argb(248, 255, 255, 255));
_paintSimple.setStrokeWidth(20f);
_paintSimple.setStyle(Paint.Style.STROKE);
_paintSimple.setStrokeJoin(Paint.Join.ROUND);
_paintSimple.setStrokeCap(Paint.Cap.ROUND);
_paintBlur = new Paint();
_paintBlur.set(_paintSimple);
_paintBlur.setColor(Color.argb(235, 74, 138, 255));
_paintBlur.setStrokeWidth(30f);
_paintBlur.setMaskFilter(new BlurMaskFilter(15, BlurMaskFilter.Blur.NORMAL));
并绘制两次我Path()
:
@Override
protected void onDraw(Canvas canvas) {
canvas.drawPath(mPath, _paintBlur);
canvas.drawPath(mPath, _paintSimple);
}
您能不能给更多的代码? – pengwang 2011-06-12 08:37:12
当然。编辑我的答案。 – sharl 2011-06-14 08:04:56
什么是** mPath ** ?? 我做了新的变种。同名 Path mPath = new Path(); 不改变! – Realbitt 2013-06-22 08:15:50