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 <init>
08-22 14:55:00.519 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView <init>
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

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值