When does the view get its borders?

I have a main Activity with a TextView on it. I need to follow some steps when starting the application. These actions use the bounds of the TextView .

I tried to override the onCreate() , onStart() and onResume() , but TextView bound is always (0,0).

How can I capture when TextView gets its size?

Thanks everyone!

+4
source share
2 answers

You can try onWindowFocusChanged() and see if this helps:

This is the best indicator of whether this activity is visible to the user. The default implementation clears the state of key tracking, so you should always call it.

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 a key lock, may be in front. Use onWindowFocusChanged (boolean) to know for sure that your activity is visible to the user (for example, to resume the game).

+1
source

The moment you search, onMeasure ().

0
source

Source: https://habr.com/ru/post/1399815/


All Articles