Creating completely new Views gives you the power to fundamentally shape the way your applications look and feel. By creating your own controls you can create user interfaces that are uniquely suited to your users' needs. To create new controls from a blank canvas you extend either the View or SurfaceView classes.
The View class provides a Canvas object with a series of draw methods and Paint classes. Use them to create a visual interface with bitmaps and raster graphics. You can then override user events like screen touches or key presses to provide interactivity. In situations in which extremely rapid repaints and 3D graphics aren't required, the View base class offers a powerful lightweight solution.
The SurfaceView class provides a Surface object that supports drawing from a background thread and using openGL for 3D graphics. This is an excellent option for graphics-heavy controls that are frequently updated or that display complex graphical information, particularly games and 3D visualizations.
This chapter introduces 2D controls based on the View class. To learn more about the SurfaceView class and some of the more advanced Canvas paint features available in Android, see Chapter 15.
Was this article helpful?
Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.