简体   繁体   中英

Android WEAR, Notification background while in Ambient mode

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM