0
paint
a drawCircle
是否可以用图像而不是颜色?如果是这样,怎么样?如果不是,我有没有办法让它看起来像?谢谢。drawCircle绘制位图?
paint
a drawCircle
是否可以用图像而不是颜色?如果是这样,怎么样?如果不是,我有没有办法让它看起来像?谢谢。drawCircle绘制位图?
您可以在您的Canvas
上以所需的坐标绘制多个图像,就像您可以绘制圆圈一样。正确使用setBounds方法来指定您希望绘制图像的确切坐标。以下是一个示例代码:
public class MyDrawableView extends View {
private Drawable mD1;
private Drawable mD2;
public MyDrawableView(Context context) {
super(context);
Resources res = context.getResources();
mD1 = res.getDrawable(R.drawable.image1);
//Set image1 bounds using : mD1.setBounds(x, y, x + width, y + height);
mD2 = res.getDrawable(R.drawable.image2);
//Set image2 bounds using : mD2.setBounds(a, b, a + width, b + height);
}
protected void onDraw(Canvas canvas) {
mD1.draw(canvas);
mD2.draw(canvas);
}
}