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

UITableView Not refreshing after Modal View Controller dismisses

iphone uitableview iphone-sdk-3.0

My UITable View does not refresh from its data source of an array, which is edited but the Modal view controller.

Gtkglextmm and Gtkmm3

c++ opengl gtk gtk3 gtkmm

I work on a Gtkmm-3.0 project and I want to use the openGl Gtk exentsion Gtkglextmm. But it seems to me that the actual version of gtkglextmm-1.2 supports only gtkmm-2.x.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.