Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - when is performTraversals called?

Tags:

android

views

I'm curious guys,

What are the exact cases doTraversal -> performTraversals is called? Since I have pretty heavy Activity, I want the application to call onDraw or the sort. performTraversals is pretty heavy, it is trying/measuring if it should resize views, stuff like that I guess. And I don't need it when I'm making some view, that no other view is dependent on, GONE, but I guess I can't skip that. So before digging into the source of Android, I want to ask. If you know it, please feel free to share :)

Thanks, Danail

like image 862
Danail Avatar asked Oct 04 '12 17:10

Danail


1 Answers

performTraversals() has many jobs but its three main roles are:

  • Measure views
  • Layout views
  • Draw views

Every time Android needs to redraw a window, performTraversals() is invoked. It does not mean however that measure/layout happens every time performTraversals() executes. You cannot skip performTraversals() if you are using a standard views (only SurfaceView lets you bypass this when drawing.)

like image 84
Romain Guy Avatar answered Oct 31 '22 17:10

Romain Guy