- View的Life Cycle主要經過onMeasureàonLayoutàonDraw三個步驟
- View的進行過程是遞迴的概念,最先處理的是View中最小的地方,由下圖範例,執行順序為CàBàA
- onMeasure主要是測量在Layout中此view的大小
- onLayout負責將View放在Layout對應的位置中
- 當程式執行addView將某個View加進Layout時,會在呼叫requestLayout
public void addView(View child, int index, LayoutParams params) {
// addViewInner() will call child.requestLayout() when setting the new LayoutParams
// therefore, we call requestLayout() on ourselves before, so that the child's
// request will be blocked at our level
requestLayout();
addViewInner(child, index, params, false);
}
- requestLayout就會執行onMeasure和onLayout
文章標籤
全站熱搜
