2

On Going through public void onDraw (Canvas canvas, Rect bounds) method in CanvasWatchFaceService.Engine. The docs says

Draws the watch face.
Parameters
canvas  the canvas to draw into
bounds  the bounds in which the watch face should be drawn

Is there any case the bounds could be different than the height and width of canvas?

Also how is it different from width and height retrieved from public void onSurfaceChanged (SurfaceHolder holder, int format, int width, int height)

Gaurav Vashisth
  • 7,547
  • 8
  • 35
  • 56

1 Answers1

2

I'm only speculating here, but it seems to me that they could be different, since the bounds (Rect) is the dimensions of the canvas, while the width and height pertain to the view being rendered.

Technically, you can draw outside the bounds of the canvas, but I imagine the OS wouldn't do this itself.

A good reference is the Muzei source code - look at the onSurfaceChanged and onPeekCardPositionUpdate methods.

Yuri Schimke
  • 12,435
  • 3
  • 35
  • 69
wes
  • 66
  • 3
  • 3