开发者

Subclassing view and onDraw()

开发者 https://www.devze.com 2023-01-28 04:09 出处:网络
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 ne开发者

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 ne开发者_如何学Pythoned 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.

Thanks


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

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.

http://code.google.com/p/calculus-tools/source/browse/DerivativeLibrary/src/com/andymc/derivativelibrary/GraphView.java


The Android API demos are full of great examples. They're on your local computer in the Android SDK under "samples/". You can also see them online. The "graphics" subsection in particular has lots of examples with Views that override onDraw.

As a random example, check out DrawPoints.java.

0

精彩评论

暂无评论...
验证码 换一张
取 消