Wednesday, August 7, 2013

Custom view will not render

If you have ever created a custom view, one which inherit from ViewGoup, and by chance had no Children... actual View children, and then tried to override its onDraw(...), or draw(...), and you have called invalidate in vain, debugged for far too long only to find out that view will not render...

Well the reason actually makes sense, it is a container... there are no children SO... DO NOT RENDER!

But still, it might have a background... ?

In any case to solve this, you are required to add the following line to all of your custom view constructors:


This would force the view group to render... although it has no children.

No comments:

Post a Comment