view 的 post 执行时,首先会判断view 的 mAttatchInfo 是否为空,如果不为空,则将Runnable 添加到mAttachInfo.handler 的 UI线程MessageQueue 中;如果为空,则先将Runnable 暂存在view 的类为HandlerActionQueue的mRunQueue中,在ViewRootImpl 中第一次执行performTransval时执行 dispatchAttachedToWindow ,在这个方法中执行 mRunQueue.executeActions(mAttachInfo.handler),这样就能保证Runnable 运行时获取到获取到view的宽高,因为这个时候首次performTransval已经执行完,首次测量工也会执行完,之后才会执行这个Runnable,所以这个时候能获取到宽高
相关推荐
勿问东西18 分钟前
【Android】设备操作五味香25 分钟前
C++学习,信号处理图王大胜2 小时前
Android Framework AMS(01)AMS启动及相关初始化1-4工程师老罗4 小时前
Android Button “No speakable text present” 问题解决小雨cc5566ru5 小时前
hbuilderx+uniapp+Android健身房管理系统 微信小程序z488g小雨cc5566ru6 小时前
微信小程序hbuilderx+uniapp+Android 新农村综合风貌旅游展示平台小雨cc5566ru6 小时前
小程序 uniapp+Android+hbuilderx体育场地预约管理系统的设计与实现佛系小嘟嘟8 小时前
Android-由switch-case和view.getId()引起的bug:错误:需要常量表达式 的解决办法勿问东西8 小时前
【Android】事件连连斯基11 小时前
Android Framework(八)WMS-窗口动效概述