Question

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!

Était-ce utile?

La solution

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).

Autres conseils

The moment you are looking for is onMeasure().

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top