Android Custom Layout - onDraw() never gets called

白昼怎懂夜的黑 提交于 2019-11-27 11:26:27

By default, onDraw() isn't called for ViewGroup objects. Instead, you can override dispatchDraw().

Alternatively, you can enable ViewGroup drawing by calling setWillNotDraw(false) in your TableView constructor.

EDIT:

For #2: - Initialize it in the constructor, then just call rect.set() in your onLayout() method.

For #3: - Yes, as far as I'm aware the super call will handle it, you shouldn't have to handle that unless you need to customize the way the children are drawn.

If you want that the canvas is be re-draw call invalidate(), and the method onDraw() will be re-executed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!