如何把画布上的ImageView的机器人 [英] How to take canvas on imageview in android

查看:138
本文介绍了如何把画布上的ImageView的机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在安卓上的ImageView显示画布内容

我不理解的 imageview.draw(画布);

这是我的code:

 公共类矩阵扩展活动{
    公共位图MYBITMAP,newbmp,位图,BMP;
    ImageView的ImageView的;

    涂料粉刷;
    @覆盖
    公共无效的onCreate(最终捆绑savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.main);
        ImageView的=(ImageView的)findViewById(R.id.ImageView01);
        imageview.setDrawingCacheEnabled(真正的);
    }

    保护无效的OnDraw(帆布油画)
    {
        imageview.draw(画布);
        MYBITMAP = BitmapFactory.de codeResource(getResources(),R.drawable.image);
        canvas.drawBitmap(MYBITMAP,0,0,油漆);
    }

}
 

解决方案

我想在安卓上的ImageView显示画布上的内容

所以,你想画什么就画布到您的ImageView?如果这是你想要的,那么你需要读取johike给出的链接,因为你似乎已经成为糊涂一点。

下面在code:

  imageview.draw(画布);
 

不等于画油画的内容到ImageView的。这意味着相反,绘制的ImageView到画布上。

I want to display canvas contents on imageview in android

i am not understanding the imageview.draw(canvas);

Heres my code:

public class Matrix extends Activity {
    public Bitmap mybitmap,newbmp,bitmap,bmp;
    ImageView imageview;

    Paint paint;
    @Override
    public void onCreate(final Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        imageview=(ImageView)findViewById(R.id.ImageView01);
        imageview.setDrawingCacheEnabled(true);
    }

    protected void onDraw(Canvas canvas)
    {
        imageview.draw(canvas);
        mybitmap=BitmapFactory.decodeResource(getResources(), R.drawable.image);
        canvas.drawBitmap(mybitmap, 0, 0, paint);
    }

}

解决方案

"I want to display canvas contents on imageview in android"

So you want to draw what is on the Canvas in to your ImageView? If that's what you want then you need to read the links given by johike because you seem to have become confused a little.

The following in your code:

imageview.draw(canvas);

Does NOT mean draw the contents of canvas in to the imageview. It means the opposite, draw the imageview to the canvas.

这篇关于如何把画布上的ImageView的机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆