0

I am currently designing a library. This library presents UI elements that 'target' other elements already drawn on the screen. It does this by passing in a View object. However, Activities do not actually draw contents until later on in its lifecycle, making method calls like getHeight() and getWidth() useless.

Is there a way for me to perhaps pass in the instance of an activity (as a weakReference for good measure), to one of my library's class and 'listen' for when the contents have been drawn?

rperryng
  • 3,233
  • 3
  • 22
  • 35

1 Answers1

0

Use viewTreeObserver class .Register this observer and you will get a callback after the view has been drawn.

When Can I First Measure a View?

Community
  • 1
  • 1
arul
  • 190
  • 2
  • 15