The parameter to onDraw() is a Canvas object that the view can use to draw itself . ... In order to properly draw your custom view, you need to know what size it is.
developer.android.com