嗨,我想在安卓工作室中将图像视图绘制到画布中
我发现这个代码可以绘制一个可绘制的,但我想让它绘制一个图像视图
Drawable drawable = getResources().getDrawable
(R.mipmap.ic_launcher);
drawable.setBounds(20, 30, drawable.getIntrinsicWidth()+20, drawable.getIntrinsicHeight()+30);
drawable.draw(canvas);
这就是我想要它画的
ImageView thisisImg= (ImageView)findViewById(R.id.ImageView01);
我该怎么做?感谢
只需使用ImageView中的getDrawable()
。你的例子会变成:
ImageView thisisImg= (ImageView)findViewById(R.id.ImageView01);
Drawable drawable = thisisImg.getDrawable();
drawable.setBounds(20, 30, drawable.getIntrinsicWidth()+20, drawable.getIntrinsicHeight()+30);
drawable.draw(canvas);