0

Last month Google / Jetpack released the stable version of the Watch Face library (blog post). It is stated that:

The androidx.wear.watchface package is the new recommended library for developing WearOS watch faces.

On GitHub there is a demo watch face project, made with the library, which includes many features. However, it does not explain how to add a background.

How should I add a background image to a androidx.wear.watchface-based watch face?

Bastiaan Quast
  • 2,802
  • 1
  • 24
  • 50

1 Answers1

0

The change to the is probably just to replace the background color.

https://github.com/android/wear-os-samples/blob/19726c10ac0c881c9d748400294fdb6bb9585ab7/WatchFaceAlphaKotlin/app/src/main/java/com/example/android/wearable/alpha/AnalogWatchCanvasRenderer.kt#L221

    val bitmap: Bitmap = TODO()
    override fun render(canvas: Canvas, bounds: Rect, zonedDateTime: ZonedDateTime) {
//        val backgroundColor = if (renderParameters.drawMode == DrawMode.AMBIENT) {
//            watchFaceColors.ambientBackgroundColor
//        } else {
//            watchFaceColors.activeBackgroundColor
//        }
//
//        canvas.drawColor(backgroundColor)

        canvas.drawBitmap(bitmap, null, bounds, null)

How are you sourcing the Bitmap? If you are downloading over the network you can use something like the following with appropriate disk caching.

How to get bitmap from URL using Coil?

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