Android itself offers many widgets, but sometimes these widgets do not meet our needs, then we need to customize the view, this article will detail the various theoretical basis of custom view, only to understand this knowledge, we can better implement the various functions of the control.
I think the most important part of the custom view is drawing and interacting, the custom drawing makes your view unique, the interaction allows the user to interact with your view, and the drawing is based on the acreage and layout of the view, and the interaction is the basis of the touch event, so acreage, layout, drawing, Touch events These are the cores of custom view.
In addition to this, a design-friendly custom view should also be able to define attributes in XML like a widget that comes with Android, which is also described in this article.
Overview of acreage, layout and drawing mechanism
Acreage, layout and plotting mechanism of view in Android
Measurement
Source code to resolve the measure acreage process in Android view
Layout
Source code to interpret the layout of view in Android
Drawing
The basics of canvas drawing in Android (with source download)
Porterduffxfermode use and working principle of canvas drawing in Android
Shader of canvas drawing in Android using graphic
Android Canvas Drawing Maskfilter text detailed (with source download)
GPU hardware acceleration control in Android and its limitations on 2D graphics rendering
Graphic detail Andorid with shape definition gradientdrawable
Touch events
Motionevent in Android
TouchEvent Touch event mechanism in Android
Defining XML Properties
Android View custom XML properties in detail and the difference between r.attr and r.styleable
I hope this article will be helpful to you, and you'll write more articles about custom view instances later.
Related reading:
My Android Blog Finishing summary
Custom view, ViewGroup theory basics in Android