Do I need to call back super.onDraw() in a custom view?

后端 未结 4 1834
情歌与酒
情歌与酒 2021-02-07 06:35

I\'m not too clear about this and neither are the docs.

When I\'m creating a custom view, I override like so:

@Override
public void onDraw(Canvas canvas)         


        
4条回答
  •  名媛妹妹
    2021-02-07 07:00

    A peek at the source code shows that View.onDraw() is an empty method. So, calling super.onDraw(), if the parent class is View itself, does nothing. It's unnecessary yet harmless.

    Whether you should go ahead and do it anyway is a separate question of efficiency, safety, and style.

提交回复
热议问题