1.declare a View object to inherit relative layout or linear layout or other viewgroup;
2, in the custom View object to rewrite its construction method, in the construction method inside the layout is initialized complete;
3, according to business needs to add some API methods, expand the custom combination of controls;
4. Expand Custom Properties:
5. Declare a namespace for the custom attribute:
Xmlns:android= "Http://schemas.android.com/apk/res/android" (the namespace that comes with the system)
xmlns:mattrs= "http://schemas.android.com/apk/res/packagename"
6.Create the Attrs.xml file under the values directory in the Res directory , declaring the properties: (refer to the SDK file platforms\android-16\data\res\values\attrs.xml)
<declare-styleable name= "Settingitemview" >
<attr name= "title" format= "string"/>
<attr name= "desc_on" format= "string"/>
<attr name= "Desc_off" format= "string"/>
</declare-styleable>
7, the layout file inside the definition of the attributes are put with (attributeset attrs) Parameters of the construction method;
8. Get Properties defined: (Get property values by namespace and property name)
Attrs.getattributevalue (string namespace, string name);
Eg: attrs.getattributevalue ("Http://schemas.android.com/apk/res/packagename", "title");
Customizing composite controls and custom properties