view 的 post 执行时,首先会判断view 的 mAttatchInfo 是否为空,如果不为空,则将Runnable 添加到mAttachInfo.handler 的 UI线程MessageQueue 中;如果为空,则先将Runnable 暂存在view 的类为HandlerActionQueue的mRunQueue中,在ViewRootImpl 中第一次执行performTransval时执行 dispatchAttachedToWindow ,在这个方法中执行 mRunQueue.executeActions(mAttachInfo.handler),这样就能保证Runnable 运行时获取到获取到view的宽高,因为这个时候首次performTransval已经执行完,首次测量工也会执行完,之后才会执行这个Runnable,所以这个时候能获取到宽高
相关推荐
2601_9498333920 分钟前
flutter_for_openharmony口腔护理app实战+知识实现晚霞的不甘21 分钟前
Flutter for OpenHarmony从基础到专业:深度解析新版番茄钟的倒计时优化鸟儿不吃草1 小时前
android的Retrofit请求https://192.168.43.73:8080/报错:Handshake failedMinilinux20181 小时前
Android音频系列(09)-AudioPolicyManager代码解析李子红了时1 小时前
【无标题】Android系统攻城狮3 小时前
Android tinyalsa深度解析之pcm_close调用流程与实战(一百零四)weixin_411191843 小时前
LifecycleEventObserver和DefaultLifecycleObserver使用、BeYourself3 小时前
Intent :跳转与数据传递的正确打开方式灵感菇_3 小时前
Android 列表控件全面解析:ListView 与 RecyclerView2601_949809594 小时前
flutter_for_openharmony家庭相册app实战+照片详情实现