0

I have created a new Watchface using Android WEAR 1.4 SDK but when the watch goes in Ambient mode the current notification has a transparent background so the text overlay the watchface and it looks ugly.

I have downloaded some third party watchfaces and found out that you can draw a background black behind the notification in ambient mode. How can I do that? Android WEAR SDK doesn't have any link about this

Raffaeu
  • 6,694
  • 13
  • 68
  • 110
  • Can you please post how you are creating your notification? Have you tried setting the background of the notification? https://developer.android.com/reference/android/support/v4/app/NotificationCompat.WearableExtender.html#setBackground%28android.graphics.Bitmap%29 – dazza5000 Dec 23 '15 at 13:36
  • I am not creating any notification. These are the notifications raised by WEAR while my face is running. If it's ambient mode, all notifications have transparent background and white text but this is not something I am controlling from my watchface. – Raffaeu Dec 23 '15 at 13:37
  • 1
    Thank you for the clarification :) – dazza5000 Dec 23 '15 at 13:39
  • 1
    It looks like this is the event and the dark background should actually be drawn on top of the watchface to highlight the card in ambient mode http://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#onPeekCardPositionUpdate(android.graphics.Rect) – Raffaeu Dec 23 '15 at 14:27
  • 1
    Awesome. Please post back if that works! – dazza5000 Dec 23 '15 at 15:24

1 Answers1

3

I have found directions for a solution by reading this post: Get height of peek card before any are displayed?

So, first of all, you need to know if the card is visible, because if there are no cards visible than it doesn't make sense to continue. With API 1.3 you can get back the Rect used by the Card to draw itself:

Rect card = getPeekCardPosition();

So technically, every time you paint the Watchface you can check if this Rect has a Width and Height. If it has one then it means the card is visible on the screen.

Next step, maybe between a onDraw() and the next one the card has been removed by the User, this triggers an event called:

onPeekCardPositionUpdate()

Where you can simply invalidate your Watchfaces and re-paint according to the new size of the card.

Community
  • 1
  • 1
Raffaeu
  • 6,694
  • 13
  • 68
  • 110