动态添加一个Android印刷品吗? [英] Dynamically add an Android canvas?

查看:121
本文介绍了动态添加一个Android印刷品吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我的画布动态添加到我的layoiut但有错误:
说明位置资源路径类型
在类型的ViewGroup的方法addView(查看)不适用于参数(Canvas)的Java问题

 画布油画=新的Canvas();
LL的LinearLayout =新的LinearLayout(本);
ll.addView(画布);


解决方案

有可能是一个根本性的错误你的问题。你实际上并没有增加画布,以一个视图。
您可以使用画布通过重写的onDraw方法在视图中(即SurfaceView)来绘制。


看看这个博客,怎么画布可以在Android中使用:
[http://www.tutorialforandroid.com/2010/11/dr​​awing-with-canvas-in-android-renewed.html][1]

I want to dynamically add my canvas to my layoiut but this has the error: Description Location Resource Path Type The method addView(View) in the type ViewGroup is not applicable for the arguments (Canvas) Java Problem

Canvas canvas = new Canvas();
LinearLayout ll = new LinearLayout(this);
ll.addView(canvas);

解决方案

There might be something fundamentally wrong with your question. You don't actually "add a canvas" to a view. You use the canvas to draw in a view (ie. SurfaceView) by overriding the onDraw method.

Have a look at this blog, how the canvas can be used in Android: [http://www.tutorialforandroid.com/2010/11/drawing-with-canvas-in-android-renewed.html][1]

这篇关于动态添加一个Android印刷品吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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