6.3.1. Attaching a Custom View to a Layout

You can create a custom view by extending class View or one of its subclasses, as we do with class CannonView (Section 6.8), which extends SurfaceView (discussed shortly). To add a custom component to a layout’s XML file, you must provide its fully qualified name (i.e., its package and class name), so the custom View’s class must exist before you add it to the layout. We demonstrate how to create the CannonView class and add it to a layout in Section 6.4.3.

Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.