android view事件顺序
16lz
2021-01-24
单一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 onFinishInflate08-22 14:55:00.527 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onFinishInflate08-22 14:55:00.552 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onMeasure08-22 14:55:00.553 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onMeasure08-22 14:55:00.554 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onMeasure08-22 14:55:00.564 10266-10290/com.milog.test.mytest I/ViewRootImpl: W::resized reportDraw:true frame:Rect(60, 774 - 1020, 1220) newConfig:null08-22 14:55:00.574 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onMeasure08-22 14:55:00.575 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onMeasure08-22 14:55:00.575 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onMeasure08-22 14:55:00.576 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onSizeChanged08-22 14:55:00.576 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onSizeChanged08-22 14:55:00.576 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onLayout true08-22 14:55:00.576 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onLayout true08-22 14:55:00.583 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onMeasure08-22 14:55:00.584 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onMeasure08-22 14:55:00.596 10266-10290/com.milog.test.mytest I/ViewRootImpl: W::resized reportDraw:true frame:Rect(108, 774 - 972, 1220) newConfig:null08-22 14:55:00.603 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onSizeChanged08-22 14:55:00.603 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onSizeChanged08-22 14:55:00.603 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onLayout true08-22 14:55:00.603 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onLayout true08-22 14:55:00.604 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onDraw08-22 14:55:00.604 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onDraw08-22 14:55:00.629 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onMeasure08-22 14:55:00.630 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onMeasure08-22 14:55:00.630 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onLayout false08-22 14:55:00.630 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onLayout false08-22 14:55:01.763 10266-10266/com.milog.test.mytest I/System.out: MiloDialog onDraw08-22 14:55:01.764 10266-10266/com.milog.test.mytest I/System.out: TypeSetTextView onDraw
更多相关文章
- C语言函数的递归(上)
- Android(安卓)NDK之二:创建NativeActivity
- Android(安卓)获取验证码倒计时实现
- [置顶] Android(安卓)IPC 通讯机制源码分析【下】
- Android用户界面
- android4.4.2 bluetooth解析(二)
- Android(安卓)NDK学习笔记11-JNI异常处理
- Android(安卓)Zygote进程源码分析
- android上的漏洞挖掘方式和Fuzz