Android 自定义View中,四个参数的构造函数的含义
MyView(Context context) Used when instanciating Views programmatically. MyView(Context context, AttributeSet attrs) Used by the LayoutInflater to apply xml attributes. If one of this attribute is named style , attributes will be looked up the the style before looking for explicit values in the layout xml file. MyView(Context context, AttributeSet attrs, int defStyleAttr) Suppose you want to apply a default style to all widgets without having to specify style in each layout file. For an example make all checkboxes pink by default. You can do this with defStyleAttr and the framework will lookup