android view事件顺序

单一view顺序为:

  init构造函数 -- onFinishInflate -- onMeasure -- onSizeChanged -- onLayout -- onDraw

子类和父类顺序为:

父类init构造函数 -- 子类init构造函数 -- 子类onFinishInflate -- 父类onFinishInflate --

子类onMeasure --父类onMeasure -- 父类onSizeChanged -- 子类onSizeChanged --

子类onLayout -- 父类onLayout -- 父类onDraw -- 子类onDraw

整体顺序为:父-子-子-父 这样来回循环。

从下方可以看出onLayout false时亦为onSizeChanged 未调用时。该参数为onLayout 第一个参数 changed。

 

由于手机禁了Log.d 的输出,暂用System.out来代替,也可以用Log.e或Log.w等较高级别的日志来输出。

08-22 14:55:00.507 10266-10266/com.milog.test.mytest I/System.out: MiloDialog 
08-22 14:55:00.519 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView 
08-22 14:55:00.520 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onFinishInflate
08-22 14:55:00.527 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onFinishInflate
08-22 14:55:00.552 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onMeasure
08-22 14:55:00.553 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onMeasure
08-22 14:55:00.554 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onMeasure
08-22 14:55:00.564 10266-10290/com.milog.test.mytest I/ViewRootImpl: W::resized  reportDraw:true  frame:Rect(60, 774 - 1020, 1220)  newConfig:null
08-22 14:55:00.574 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onMeasure
08-22 14:55:00.575 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onMeasure
08-22 14:55:00.575 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onMeasure
08-22 14:55:00.576 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onSizeChanged
08-22 14:55:00.576 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onSizeChanged
08-22 14:55:00.576 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onLayout true
08-22 14:55:00.576 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onLayout true
08-22 14:55:00.583 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onMeasure
08-22 14:55:00.584 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onMeasure
08-22 14:55:00.596 10266-10290/com.milog.test.mytest I/ViewRootImpl: W::resized  reportDraw:true  frame:Rect(108, 774 - 972, 1220)  newConfig:null
08-22 14:55:00.603 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onSizeChanged
08-22 14:55:00.603 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onSizeChanged
08-22 14:55:00.603 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onLayout true
08-22 14:55:00.603 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onLayout true
08-22 14:55:00.604 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onDraw
08-22 14:55:00.604 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onDraw
08-22 14:55:00.629 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onMeasure
08-22 14:55:00.630 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onMeasure
08-22 14:55:00.630 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onLayout false
08-22 14:55:00.630 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onLayout false
08-22 14:55:01.763 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onDraw
08-22 14:55:01.764 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onDraw

 

你可能感兴趣的:(android)