0

In my custom Android view, I will at some point call requestLayout() after I've changed my layout parameters. I'm overriding onDraw(...) so I also need to make sure invalidate() is called.

However, is it necessary to call invalidate() after requestLayout()?

Say that I don't, and I trust Android to do it for me after requestLayout(). It may be that what I've changed in my layout parameters changed nothing at all. Will Android detect this and avoid calling invalidate() in this edge case, or am I guaranteed that invalidate() will be called no matter what?

Edit: This is not a duplicate of Usage of forceLayout(), requestLayout() and invalidate(). I am specifically asking if there is some exempt in the Android code, e.g. if (newWidth == oldWidth && newHeight == oldHeight) return; // no need to invalidate? I would still like to invalidate even if my layout parameters did not change. In other words, does Android docs somewhere guarantee that invalidation will occur?

Community
  • 1
  • 1
HelloWorld
  • 3,381
  • 5
  • 32
  • 58

0 Answers0