我想用这样
的发光效果画线问题 - 我必须根据用户的交互在程序中生成这条线(线的形式将在onTouchEvent
-中生成ACTION_MOVE
)。
我可以在没有 xml 文件或绘制 premaid 位图的情况下生成这种效果吗?
我想用这样
的发光效果画线问题 - 我必须根据用户的交互在程序中生成这条线(线的形式将在onTouchEvent
-中生成ACTION_MOVE
)。
我可以在没有 xml 文件或绘制 premaid 位图的情况下生成这种效果吗?
我以这种方式模仿这种效果:
BlurMaskFilter
用;画线我使用 Path 类生成线并保存MOVE_ACTION
事件坐标以仅生成我需要的部分路径。
创建 2Paint()
秒:
_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);
}