android 在 Activity 的 onCreate 中获取View 的宽高

view 的 post 执行时,首先会判断view 的 mAttatchInfo 是否为空,如果不为空,则将Runnable 添加到mAttachInfo.handler 的 UI线程MessageQueue 中;如果为空,则先将Runnable 暂存在view 的类为HandlerActionQueue的mRunQueue中,在ViewRootImpl 中第一次执行performTransval时执行 dispatchAttachedToWindow ,在这个方法中执行 mRunQueue.executeActions(mAttachInfo.handler),这样就能保证Runnable 运行时获取到获取到view的宽高,因为这个时候首次performTransval已经执行完,首次测量工也会执行完,之后才会执行这个Runnable,所以这个时候能获取到宽高

相关推荐
Kaede621 分钟前
MySQL中如何使用命令行修改root密码
android·mysql·adb
明君879972 小时前
Flutter 图纸标注功能的实现:踩坑与架构设计
android·ios
成都大菠萝2 小时前
Android Auto开发(3)-Audio Integration
android
成都大菠萝2 小时前
Android Auto开发(5)-Audio Integration
android
泡沫·2 小时前
7.LAMPLNMP 最佳实践
android
码码宁3 小时前
六个故事搞懂Fragment 故事1-初识Fragment - NewsHub的模块化革命
android
成都大菠萝3 小时前
Android Auto开发(0)-引言
android
q***33374 小时前
SpringMVC新版本踩坑[已解决]
android·前端·后端
F***74174 小时前
数据库课设---酒店管理系统(MySQL、VBNet)
android·数据库·mysql
踢球的打工仔4 小时前
PHP面向对象(5)
android·java·php