【发布时间】:2013-12-10 06:06:56
【问题描述】:
我试图在 onDraw() 中将 jpg 绘制到画布上,但是 Bitmap 类型似乎不可绘制(没有 .draw 方法)。我的目标是制作一个可以通过触摸/拖动在屏幕上移动的 jpeg。这个要怎么画?
这是我的构造函数(我将图像路径传递给视图)
public TouchViewClass(Context context, AttributeSet attrs, int defStyle, String picPath) {
super(context, attrs, defStyle);
this.picPath=picPath;
}
这是我的 onDraw
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
Bitmap myImg = BitmapFactory.decodeFile(picPath);
canvas.save();
canvas.translate(mPosX, mPosY);
//Here is where the bitmap should be drawn
canvas.restore();
}
【问题讨论】:
-
有点搞砸了,我会对我的问题投反对票。有人可以帮我理解这个问题有什么问题吗?
标签: android android-canvas android-ui