在 Canvas 绘图中,如何移动由路径创建的 ShapeDrawble 对象才有效?
下面的代码貌似是通过新的路径来移动,所以每次都要重新创建ShapeDrawable对象。这非常浪费资源,有什么办法解决吗?
private void drawBitmapShape(Canvas canvas, Paint paint)
{
/*Draw a hollow triangle*/
Path path=new Path();
path.moveTo(10, 330);
path.lineTo(70,330);
path.lineTo(40,270);
path.close();
//canvas.drawPath(path, paint);
/* create ShapeDrawable object and define the shape is elliptic */
mShape = new ShapeDrawable(new PathShape(path, BitQQheight, BitQQheight));
/* set up the ellipse things to draw for ShapeDrawable pictures */
mShape.getPaint().setShader(mBitmapShader);
/*set display area*/
//BitQQheight=BitQQheight*2;
mShape.setBounds(0,0, BitQQwidth, BitQQheight);
/* draw ShapeDrawableQQ */
mShape.draw(canvas);
}