Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Creating your custom UI components starts with extending a view class. You can extend the base View class for maximum configurability, or you can start with one of the existing view classes and add the functionality you need. Which choice you should make depends on your application needs. The basic implementation is the same either way: extend the view and override the appropriate methods, adding your customized code along the way.
This only applies to static views or low-performance 2D graphics. If you want to create 3D graphics or complex animations, you should extend SurfaceView or use either RenderScript or OpenGL. See Chapter 11 for more details on advanced graphics.
To learn how to create custom views, you’re going to create a simple custom view that displays two lines in the shape of a cross (Figure 10.1). To start, create a new class called CrossView that extends the View class: