4

I was trying to use textView.getTop() method but getting only 0. And I used the onPreDraw() method as kcoppock said in this question.

However, the onPreDraw() method was called twice in my situation.

I can handle that but I just want to know when is the onPreDraw() method called exactly. The google's documentation says it's invoked when the view tree is about to be drawn. What's that actually mean?

Could any buddy tell me or show me where to find the answer? Thx!

Community
  • 1
  • 1
FrankSu
  • 331
  • 1
  • 4
  • 10
  • Hey there, did you end up finding out why the onPreDraw was being called twice? –  Dec 15 '14 at 15:52

1 Answers1

2

The listener will report all onPreDraw() until you remove the listener. If you only want to receive one onPreDraw() report, try the new androidx OneShotPreDrawListener

Teng-pao Yu
  • 1,313
  • 15
  • 30