如果构造函数中没有
this.setWillNotDraw(false)这句话时候
onDraw函数始终不被调用 直到添加上之后才可以成功调用onDraw函数
仔细查看onDraw函数的说明:
public void setWillNotDraw (boolean willNotDraw)
Since:
API Level 1
If this view doesn't do any drawing on its own, set this flag to allow further optimizations. By default, this flag is not set on View, but could be set on some View subclasses such as ViewGroup. Typically, if you overrideonDraw(Canvas)
you should clear this flag.
总之,要想再自定义的画一些东西 就要进行setWillNotDraw(false).
2.如果你有两个容器 A 和 a,a是放在A之中。如果都对这两个容器设置了
setWillNotDraw(false),那么你将会看到一个“奇迹":a中被添加进来的控件都不透明了。