如何从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 :(得分:1)
您已经改进了onDraw方法plz检查
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
imageBack = BitmapFactory.decodeResource(getResources(), R.drawable.background);
imageBack.setBounds(0,0,getWidth(),getHeight());
imageBack.draw(canvas);
}
你不是很清楚。所以,如果您发现任何困难,您可以在我的帖子中添加评论