diff --git a/docs/html/training/wearables/watch-faces/drawing.jd b/docs/html/training/wearables/watch-faces/drawing.jd index 8b6de761e1448..30a7a6f7b62eb 100644 --- a/docs/html/training/wearables/watch-faces/drawing.jd +++ b/docs/html/training/wearables/watch-faces/drawing.jd @@ -457,9 +457,23 @@ watch face. The bounds take into account any inset areas, such as the "chin" on round devices. You can use this canvas to draw your watch face directly as follows:
onDraw()
-method, scale your background to fit.onSurfaceChanged()
+method to scale your background to fit the device any time the view changes.
+
+@Override
+public void onSurfaceChanged(
+ SurfaceHolder holder, int format, int width, int height) {
+ if (mBackgroundScaledBitmap == null
+ || mBackgroundScaledBitmap.getWidth() != width
+ || mBackgroundScaledBitmap.getHeight() != height) {
+ mBackgroundScaledBitmap = Bitmap.createScaledBitmap(mBackgroundBitmap,
+ width, height, true /* filter */);
+ }
+ super.onSurfaceChanged(holder, format, width, height);
+}
+
+