10. Creating Custom Views
The Android view framework provides a rich visual toolkit with which to create your application UI. However, you may find that the functionality you need is not available in the stock views. For those cases, Android allows you to create a custom view that will better match your needs. In this chapter, you will learn that Android draws views in two passes, a measure phase and a layout phase; that you should override the onMeasure
and onDraw
methods when creating a custom view; that using custom view attributes requires that you declare a new XML namespace for those attributes; and that compound views combine multiple views into a custom component.
Understanding How Android Draws Views
Before learning how to create custom ...
Get Android UI Fundamentals: Develop and Design 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.