普通控件
     1、继承View类或者其子类,并重写public MyViewDemo(Context context, AttributeSet attrs)构造方法。
     2、重写onMeasure方法,设置控件的大小
     3、重写onDraw方法,实现控件的绘制
     4、添加自定义控件到布局文件中。注意是全类名
 
  添加属性控件
    1、继承View类或者其子类,并重写public MyViewDemo(Context context, AttributeSet attrs)构造方法。
    2、在value目录下写resource文件
        <resources>
         <!--添加属性集-->
         <declare-styleable name="Theme">
              <!--添加具体属性-->
              <attr name="colorForeground" format="color" />
         </declare-styleable>
        </resources>
    3、在构造方法中解析xml文件。
    4、重写onMeasure方法,设置控件的大小
    5、重写onDraw方法,实现控件的绘制
    6、在布局文件中加上自定义控件的命名控件:如
      xmlns:example="http://schemas.android.com/apk/res/包名"
    7、添加自定义控件到布局文件中。注意是全类名