android onDraw 不执行,不调用

来源:互联网 发布:淘宝 双十一 编辑:程序博客网 时间:2024/04/28 01:56

在ViewGroup中ondraw总是不执行,或者说不被调用.

原因:if a ViewGroup background is null ,the funtion "ondraw" will not be call., but the "dispatchDraw" always will be call.


结论出处:

onDraw(...) in LinearLayout
Parameters:
canvas the canvas on which the background will be drawn
SDK中的注释隐约提到 LinearLayout 中的方法onDraw是用来绘制背景的.