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,所以这个时候能获取到宽高

相关推荐
2601_9498333920 分钟前
flutter_for_openharmony口腔护理app实战+知识实现
android·javascript·flutter
晚霞的不甘21 分钟前
Flutter for OpenHarmony从基础到专业:深度解析新版番茄钟的倒计时优化
android·flutter·ui·正则表达式·前端框架·鸿蒙
鸟儿不吃草1 小时前
android的Retrofit请求https://192.168.43.73:8080/报错:Handshake failed
android·retrofit
Minilinux20181 小时前
Android音频系列(09)-AudioPolicyManager代码解析
android·音视频·apm·audiopolicy·音频策略
李子红了时1 小时前
【无标题】
android
Android系统攻城狮3 小时前
Android tinyalsa深度解析之pcm_close调用流程与实战(一百零四)
android·pcm·tinyalsa·音频进阶·音频性能实战·android hal
weixin_411191843 小时前
LifecycleEventObserver和DefaultLifecycleObserver使用
android
、BeYourself3 小时前
Intent :跳转与数据传递的正确打开方式
android·android-studio
灵感菇_3 小时前
Android 列表控件全面解析:ListView 与 RecyclerView
android·ui
2601_949809594 小时前
flutter_for_openharmony家庭相册app实战+照片详情实现
android·java·flutter