Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View draw complete callback

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.

like image 397
Bord81 Avatar asked Nov 02 '25 20:11

Bord81


2 Answers

yourView.post(someRunnable) ensures, that someRunnable will be executed after the view is laid out and drawn.

like image 103
azizbekian Avatar answered Nov 04 '25 13:11

azizbekian


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.
}
like image 25
Siegmeyer Avatar answered Nov 04 '25 12:11

Siegmeyer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!