Free Sample
+ Collection

Learning Android Canvas

Mir Nauman Tahir

If you want to create 2D graphics for Android from scratch, this book is the perfect guide. It covers all the angles of using Android Canvas with a step-by-step approach to give your apps the graphical edge.
RRP $17.99
RRP $29.99
Print + eBook

Want this title & more?

$12.99 p/month

Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.

Book Details

ISBN 139781783285396
Paperback108 pages

About This Book

  • Understand user interactions and respond to those actions
  • Discover how to work with graphics in Android from scratch
  • Using a step by step approach, create a graphics-rich, fully functional application
  • Use Nine-Patch image

Who This Book Is For

This book is a great resource for developers who have basic Android development knowledge and want to work on graphics-rich applications and games but are totally new to working with graphics and Android Canvas.

Table of Contents

Chapter 1: Getting Started with Android Canvas
Android Canvas
Our first Android Canvas application
Mining our first application
Chapter 2: Drawing Threads
The need for drawing threads
The issue with multithreading in Android
The Thread class
Chapter 3: Drawing and Drawables in Android Canvas
Drawing on a Canvas
Shape Drawables
Chapter 4: NinePatch Images
Creating a NinePatch image
Using a NinePatch image
Chapter 5: Touch Events and Drawing on Canvas
Some background knowledge
Application development
Chapter 6: Putting it All Together
The story board
The project and application development

What You Will Learn

  • Create a drawable thread to take away the load from the main thread
  • Develop important drawables and shapes
  • Understand the actions performed by users, capturing them, and responding to them
  • Unfold the basics of nested layouts
  • Design your own View classes and use them in the main class
  • Discover the graphics used as backgrounds of the whole screen or controls like buttons
  • Draw on the Android Canvas and Views
  • Set up the listener for touch events

In Detail

When you're writing an application in which you would like to perform specialized drawing and/or control the animation of graphics, you should do so by drawing through a canvas. A canvas works for you as an interface to the actual surface upon which your graphics will be drawn — it holds all of your "draw" calls. Via the Android Canvas, your drawing is actually performed on an underlying Bitmap, which is placed into the window.

Learning Android Canvas is a practical guide, which will help you develop applications that contain rich 2D graphics like backgrounds, buttons, and even some small games with static 2D graphics. The book is full of step-by-step lessons and practical examples. This book helps you develop rich graphical applications and some simple games.

Learning Android Canvas will help you understand everything that is required to develop an Android application that involves creating 2D graphics from scratch to a fully functional complete application. You will start with zero knowledge of using graphics within Android applications and will then go step by step to learn about different objects and techniques. In the end you will be able to develop a complete application fully loaded with graphics and functions.

The book will give you a detailed practical explanation of Nine-Patch images and its importance in designing layouts and backgrounds. We will also take a detailed look at user interactions such as touch, capturing the action, and responding to them accordingly. Finally we will have a working, fully functional graphic application that uses all the knowledge that we have acquired previously.


Read More