子类视图的onDraw() [英] Subclassing view and onDraw()

查看:132
本文介绍了子类视图的onDraw()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个图像,一幅图像是静态意味着它不会在所有的移动,另一个图像10 * 10圈将需要移动到精确的像素上其他顶级image.Doing一些研究,我认为我需要重写的onDraw()method.Although我真的无法找到任何样品code让我开始。

I have two images,One image will be static meaning it will not move at all,another image a 10*10 circle will need to move to exact pixels on top of the other image.Doing some research I see I need to override the onDraw() method.Although I could not really find any sample code to get me started.

那么,我问是一个很好的教程或一些帮助的链接开始。

So what I am asking is a link to a good tutorial or some help getting started.

感谢

推荐答案

这是从Android开发者网站,应该给你一些背景信息的简要概述。

This is a brief overview from the Android Developer site that should give you some background information.

developer.android.com/guide/topics/graphics/index.html#draw-with-canvas

developer.android.com/guide/topics/graphics/index.html#draw-with-canvas

此外,如果你去这里你可以看到我的code绘制的图表。它会给你,你可以使用其他方法的一些例子。该的onDraw()方法是行#444请记住,您需要调用无效()你想要的视图上绘制调用每次。

Also, if you go here you can see my code for drawing a Graph. It'll give you some examples of other methods you can use. The onDraw() method is at line # 444. Keep in mind you need to call invalidate() every time you want the view to call on Draw.

<一个href=\"http://$c$c.google.com/p/calculus-tools/source/browse/DerivativeLibrary/src/com/andymc/derivativelibrary/GraphView.java\" rel=\"nofollow\">http://$c$c.google.com/p/calculus-tools/source/browse/DerivativeLibrary/src/com/andymc/derivativelibrary/GraphView.java

这篇关于子类视图的onDraw()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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