What event signifies that the draw of a View
is complete?
I know about ViewTreeObserver
listeners, but I couldn't find the 'final' one, which indicates, that the job is done.
What event signifies that the draw of a View
is complete?
I know about ViewTreeObserver
listeners, but I couldn't find the 'final' one, which indicates, that the job is done.
yourView.post(someRunnable)
ensures, that someRunnable
will be executed after the view is laid out and drawn.
What event signifies that the draw of a TextView is complete?
There is no such hook for View class (or TextView). There is, however, onDraw()
method which is called when the view should render its content.
So you can do:
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// Finished drawing. Do other stuff.
// However you must check if this is the first or subsequent call.
// Each call to "invalidate()" will trigger re-drawing.
}
If I understand your question correctly the method you are looking for is onWindowFocusChanged(boolean hasFocus)
. Or else you could try the onPostResume()
method.