Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

10. Creating Custom Views > Creating Compound Components

Creating Compound Components

Creating a custom view by extending the View class gives you the most control over your custom view. However, you will often need something simpler, such as adding functionality to an existing view. It is much easier to create a custom component by extending one of the built-in Android views and expanding its functionality. By leveraging the built-in view code, you can focus on adding enhanced functionality. A simple way to do this is by creating a new view that combines several existing views. This is called a compound component.

Creating a Compound Component

Compound components have two primary advantages over custom views. First, they leverage the existing view group classes to create the layout for you. And second, you won’t need to override the onMeasure and onDraw methods.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint