It is not very convenient for other people to use controls that are completely custom-built, because we often need to see the effects of the controls placed on the XML interface and adjust the layout based on the effects, which requires a more standard control-making process:
- Our custom controls, like other controls, should be written as a class, and the properties of this class are self-determined.
- We want to create a attrs.xml file in the Res/values directory and add the definition of the control's properties to this file.
- Use AttributeSet to complete the constructor of the control class, and in the constructor, connect the variables in the custom control class to the properties in the Attrs.xml.
- Use these already connected property variables in your custom control class.
- Define the custom control class to the XML file used in the layout.
- This custom control class object is generated and used in the interface.
This blog will refine the last piece of control authoring so that it can become a standardized custom control.