I have a main Activity with TextView on it. I need perform some actions at application startup. These actions use TextView's bounds.

I tryed override onCreate(), onStart() and onResume() methods, but TextView's bound are always (0,0).

How can I capture a moment when TextView obtains it's size?

Thanks for all!

有帮助吗?

解决方案

You could try onWindowFocusChanged() and see if it helps:

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.

This is written about onResume():

Keep in mind that onResume is not the best indicator that your activity is visible to the user; a system window such as the keyguard may be in front. Use onWindowFocusChanged(boolean) to know for certain that your activity is visible to the user (for example, to resume a game).

其他提示

The moment you are looking for is onMeasure().

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top