Android的 - 有没有被调用后onResume正确的()回调?回调、正确、Android、onResume

2023-09-05 11:12:12 作者:入魔了

有一个是被总是叫onResume()之后的回调?我需要的是,由于AFAIK,onResume(),在布局每一个视图被渲染之后,这样我就可以衡量自己的尺寸。

Is there a callback that gets always called after onResume()? I'd need that, because AFAIK, after onResume(), every View in the layout has been rendered, so I can measure their dimensions.

感谢。

推荐答案

活动| Android开发者

protected void onPostResume ()

自:API级别1

Since: API Level 1

在活动的简历完成后(onResume()被调用后)调用。应用程序通常不会实现此方法;它是用于系统类应用程序的简历code运行之后做最后的安装。

Called when activity resume is complete (after onResume() has been called). Applications will generally not implement this method; it is intended for system classes to do final setup after application resume code has run.

派生类必须通过打电话给超类的此方法的实现。如果他们不这样做,是会抛出异常。

Derived classes must call through to the super class's implementation of this method. If they do not, an exception will be thrown.

您可能也有兴趣在(在同一个链接):

You might also be interested in (in the same link):

public void onWindowFocusChanged (boolean hasFocus)

自:API级别1

Since: API Level 1

调用时的活动收益的当前窗口或失去焦点。这是该活动是否是对用户可见的最佳指标。默认实现清除键跟踪状态,所以应该总是被调用。

Called when the current Window of the activity gains or loses focus. This is the best indicator of whether this activity is visible to the user. The default implementation clears the key tracking state, so should always be called.

请注意,这提供了有关全球焦点状态,活动生命周期中的哪一个独立管理的信息。因此,虽然重点的变化通常有一定的关系生命周期的变化(即停止通常不会得到窗口焦点的活动),你不应该依赖这里的回调和那些在其他生命周期方法,如onResume之间的任何特定顺序()

Note that this provides information about global focus state, which is managed independently of activity lifecycles. As such, while focus changes will generally have some relation to lifecycle changes (an activity that is stopped will not generally get window focus), you should not rely on any particular order between the callbacks here and those in the other lifecycle methods such as onResume().

作为一般规则,但是,恢复活动将有窗口焦点......除非它已经显示了其他的对话框或者需要输入焦点弹出窗口,在这种情况下,活动本身不会有焦点时,其他窗口拥有它。同样地,该系统可以显示系统级的窗口(如在状态栏通知面板或系统警报),这将暂时取窗口输入焦点无需暂停前台活动

As a general rule, however, a resumed activity will have window focus... unless it has displayed other dialogs or popups that take input focus, in which case the activity itself will not have focus when the other windows have it. Likewise, the system may display system-level windows (such as the status bar notification panel or a system alert) which will temporarily take window input focus without pausing the foreground activity.

参数

hasFocus    Whether the window of this activity has focus.
 
精彩推荐