Android Development: How do graphics work in Android?

I am an android development beginner with some experience in other object oriented languages like java, python, c#. So I have created various games before in Java, using buffers and graphics to draw lines and stuff. How do I do that stuff in android? I looked at some online guides, and they all seem to create a class to extend a View object, and the class will overrule the onDraw method, where they can cause the Canvas or something to draw a line.

But what if you want to draw a line based on user input? That method wouldn't work then would it?

For example, what is the simplest code for which I could draw a circle where the user touches the screen?

Also, i was wondering what books people would reccomend for beginners, especially one that includes stuff on graphics? I user the developer site for android, but I feel a book would also help a lot to understand android? Any suggestoins?

Thank you for your time, I greatly appreciate it!

Answers


There you go, this book is definitely what you need to read: http://www.amazon.com/Pro-Android-Media-Developing-Smartphones/dp/1430232676

what is the simplest code for which I could draw a circle where the user touches the screen?

Either use SurfaceView to draw or create a custom View handling onDraw() and onTouch()


Here is a suggestion ... load the API Demos app into Eclipse and explore the Graphics demo source code. There are a large number of graphics demos.

To load the API Demos app, in Eclipse click File > New > Other > Android Sample Project.

Then select your build target such as Android 4.2.

Then from the list of sample apps select the API Demos app.

And finally click Finish.

There are over 300 demos in the app, so it can be difficult to navigate. You want to look in the Graphics section.


"Android 2D Graphics with Canvas API" by Yevgen Karpenko is pretty good for beginners. It explains basic concepts like coordinate systems and transformations, shows how to work with text and use different graphics primitives (lines, paths, circles, etc.). It also shows how to use multiple threads in graphics apps.

Below is the link for eBook version on Amazon.

http://www.amazon.com/Android-Graphics-Canvas-API-ebook/dp/B00DKIAVK8/ref=sr_1_8?s=books&ie=UTF8&qid=1374420538&sr=1-8&keywords=android+2d


Need Your Help

Recursive function behavior in c++

c++ recursion

I know basic definition of recursive function.....but i want to know its impact on memory??

Listbox extending off the page

c# .net silverlight xaml listbox

I have a listbox inside of a stack panel inside of a border in a silverlight application and when ever I add anything to the listbox it increases in height so the scrollbar is never used and it ext...

Why No Server Side Sockets?

java sockets jboss distributed-computing

I was perusing the JBoss Remoting documentation and I am trying to understand the reason for bidirectional transport. The documentation states that there could be security implications to allowing ...