Skip to content Skip to sidebar Skip to footer

How Do I Draw Icons On A Watch Face From An Android Wear Complication Provider?

Using the Complications API there's an icon type, but when it comes to drawing the icon I'm not sure how to do it. When I'm drawing the actual watch face there doesn't seem to be a

Solution 1:

Ok so I don't know how I missed this but it's as simple as

Drawabledrawable= icon.loadDrawable(getApplicationContext());

Then just do this which you probably already knew:

if (drawable instanceof BitmapDrawable) {
    Bitmap bitmap;
    bitmap = ((BitmapDrawable) drawable).getBitmap();
    canvas.drawBitmap(bitmap, complicationsX, mTopComplicationY, null);
}

I was looking here

https://developer.android.com/reference/android/graphics/drawable/Icon.html#loadDrawable(android.content.Context)

and then saw it and wondered why I hadn't tried that.

Edit in reponse to comment: If you want to use a VectorDrawable then adapt as necessary.

Post a Comment for "How Do I Draw Icons On A Watch Face From An Android Wear Complication Provider?"