▼ 自定義View分類
● 自定義ViewGroup
自定義ViewGroup大多繼承自ViewGroup或各種Layout钙态,包含有子View,一般是利用現(xiàn)有的組件根據(jù)特定的布局方式來組成新的組件渗磅。
● 自定義View
自定義View一般繼承自View,SurfaceView或其他的View,在沒有現(xiàn)成的View开财,需要自己實(shí)現(xiàn)的時(shí)候,就使用自定義View荣堰,不包含子View床未。
▼ 重寫的幾個(gè)方法
● 構(gòu)造方法
構(gòu)造函數(shù)是View的入口,可以用于初始化一些的內(nèi)容振坚,和獲取自定義屬性薇搁。
<pre>
public void SloopView(Context context) {}
public void SloopView(Context context, AttributeSet attrs) {}
public void SloopView(Context context, AttributeSet attrs, int defStyleAttr) {}
public void SloopView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {}
</pre>
以下方法調(diào)用的是一個(gè)參數(shù)的構(gòu)造函數(shù):
<pre>
//在Avtivity中
WuCircularStatistics view=new WuCircularStatistics(this);
</pre>
以下方法調(diào)用的是兩個(gè)參數(shù)的構(gòu)造函數(shù):
<pre>
//在layout文件中 - 格式為: 包名.View名
<com.nameWu.mainInfor.WuCircularStatistics
android:id="@+id/tab_data_circle"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</pre>
常用的就是一個(gè)參數(shù),兩個(gè)參數(shù)的構(gòu)造方法渡八,三四個(gè)參數(shù)的構(gòu)造方法以后用到了再進(jìn)行更新...