1 Define the following properties:
<resources>
<declare-styleable name= "SOCIAL_IVANDTV" >
<attr name= "Imageresource" format= "integer"/>
<attr name= "title" format= "string"/>
</declare-styleable>
</resources>
2 References in custom components (bold font):
Public Imageviewandtextview (context context, AttributeSet Attrs) {
Super (context, attrs);
TypedArray array = context.obtainstyledattributes (Attrs, r.styleable. Social_ivandtv);
ResourceId = Array.getresourceid (r.styleable. Social_ivandtv_imageresource, 0);
Content = array.getstring (r.styleable. Social_ivandtv_title);
Initview (Context );
}
3 references in the layout file:
3.1 Add a namespace at the top:
Xmlns:app ="http://schemas.android.com/apk/res/Package name"
3.2 Adding custom properties to Custom builds:
App:imageresource ="@drawable/socialweibo_icon_neutral_normal"
app:title="front"
4 Complete the work.
Android Custom Properties