Hi
如何从OnDraw()方法中绘制ImageView? canvas。()不必调用资源吗?
我正在尝试这样做
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
imageBack = BitmapFactory.decodeResource(getResources(), R.drawable.background);
canvas.drawBitmap(imageBack, (x /2)-15 ,y /2, null);
//touchEvents();
ImageView image1 = (ImageView)findViewById(R.id.ImageView01);
}
答案 0 :(得分:0)
您需要将ImageView转换为位图
ImageView image1 = (ImageView)findViewById(R.id.ImageView01);
image1.buildDrawingCache();
Bitmap bmap = image1.getDrawingCache();
然后您可以绘制bmap