* The Canvas class holds the "draw" calls. To draw something, you need * 4 basic components: A Bitmap to hold the pixels, a Canvas to host * the draw calls (writing into the bitmap), a drawing primitive (e.g. Rect, * Path, text, Bitmap), and a paint (to describe the colors and styles for the * drawing).直接查看Canvas的说明,可以看到Canvas绘图的四要素(一个位图,一个画布,要画的东西和画刷) 所以,其实你也可以再位图上绘制。但是想输出到屏幕,最终还是要借用View等对象 Bitmap bmp = Bitmap.createBitmap(100,100, Bitmap.Config.ARGB_8888); Paint paint = new Paint(); paint.setColor(Color.RED); paint.setStyle(Paint.Style.FILL); Canvas canvas = new Canvas(bmp); canvas.drawCircle(50,50,50,paint); canvas = null; ImageView imageView = (ImageView) findViewById(R.id.imageView2); imageView.setImageBitmap(bmp);
* 4 basic components: A Bitmap to hold the pixels, a Canvas to host
* the draw calls (writing into the bitmap), a drawing primitive (e.g. Rect,
* Path, text, Bitmap), and a paint (to describe the colors and styles for the
* drawing).直接查看Canvas的说明,可以看到Canvas绘图的四要素(一个位图,一个画布,要画的东西和画刷)
所以,其实你也可以再位图上绘制。但是想输出到屏幕,最终还是要借用View等对象 Bitmap bmp = Bitmap.createBitmap(100,100, Bitmap.Config.ARGB_8888);
Paint paint = new Paint();
paint.setColor(Color.RED);
paint.setStyle(Paint.Style.FILL);
Canvas canvas = new Canvas(bmp);
canvas.drawCircle(50,50,50,paint);
canvas = null;
ImageView imageView = (ImageView) findViewById(R.id.imageView2);
imageView.setImageBitmap(bmp);
也就是说,无法自己canvas.draw(bitmap,matrix,null),那样用?必须要结合用VIEW来调用才行?
你自定义Canvas的话,系统怎么去使用你的类? 除非你修改Android的framewoks。