Android的 - 帆布的drawLine内的ImageView [英] Android - Canvas drawLine inside ImageView
本文介绍了Android的 - 帆布的drawLine内的ImageView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有1的ImageView中,我要画一条线。我已经做了如下:
I've one ImageView in which I want to draw a Line. I've done the follow:
mImagenCampo = (ImageView) findViewById(R.id.imagen_campo);
crearPunto(mArea9M,mPaloIzq,v.getWidth(),mPaloIzq,Color.WHITE);
crearPunto(mArea9M, mPaloIzq,v.getWidth(), mPaloIzq,Color.WHITE);
和作用是:
private void crearPunto(float x, float y, float xend, float yend, int color) {
BitmapDrawable bmpDraw = (BitmapDrawable) mImagenCampo.getDrawable();
Bitmap bmp = bmpDraw.getBitmap().copy(Config.RGB_565, true);
Canvas c = new Canvas(bmp);
Paint p = new Paint();
p.setColor(color);
c.drawLine(x, y, xend, yend, p);
mImagenCampo.setImageBitmap(bmp);
}
我的问题是绘制的线,但它没有得到权利的坐标。它被绘制小于它应该是
My problem is that the line is drawn but It doesn't get the rights coordinates. It is drawn smaller than It should be.
感谢
编辑:我忘了说的 mImagenCampo 的是一个ImageView的
I forgot to say that mImagenCampo is an ImageView
推荐答案
试试这个:
private void crearPunto(float x, float y, float xend, float yend, int color) {
bmp = Bitmap.createBitmap(mImagenCampo.getWidth(), mImagenCampo.getHeight(), Config.ARGB_8888);
c = new Canvas(bmp);
mImagenCampo.draw(c);
Paint p = new Paint();
p.setColor(color);
c.drawLine(x, y, xend, yend, p);
mImagenCampo.setImageBitmap(bmp);
}
这篇关于Android的 - 帆布的drawLine内的ImageView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文