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!
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.