所有视图完全绘制后会触发什么事件? [英] What event is fired after all views are fully drawn?

查看:29
本文介绍了所有视图完全绘制后会触发什么事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要捕获一些 ImageView 的绝对位置以用作放置目标.我似乎无法找到我需要将代码放入什么事件才能读取屏幕并获取 Left()、Top() .. 位置.我不想监控每个人的观点的膨胀.一定有某种 onScreenFinsihed 类型的事件,但我找不到它.onMeasure 和 onDraw 似乎在他们的工作开始时就开始工作,我需要知道他们什么时候完成.TIA.

I need to capture the absolute positions of some ImageViews to use as drop targets. I can't seem to find what event I need to put my code in to read the screen and get the Left(), Top() .. positions. I do not want monitor the inflation of each individual view. There must be some sort of onScreenFinsihed type of event, but I can't find it. onMeasure and onDraw seem to fire at the start of their work, I need to know when they are done. TIA.

推荐答案

没有这样的事件.您可以简单地在绘制序列开始时在 UI 事件队列中发布一条消息/Runnable,以便在绘制完成后执行此消息/Runnable(例如,请参见 View.post(Runnable).)此外,getLeft/getTop 返回测量和布局后的正确值,您无需等待绘图结束即可使用它们.

There is no such event. You can simply post a message/Runnable in the UI events queue at the beginning of a drawing sequence to have this message/Runnable executed after drawing is complete (see View.post(Runnable) for instance.) Also, getLeft/getTop return the correct value after measurement and layout, you don't need to wait for drawing to end to use them.

这篇关于所有视图完全绘制后会触发什么事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆