简体   繁体   English

Android WEAR,处于环境模式时的通知背景

[英]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. 我使用Android WEAR 1.4 SDK创建了一个新的表盘,但是当表进入环境模式时,当前通知具有透明背景,因此文本覆盖了表盘,并且看起来很难看。

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 Android WEAR SDK没有与此相关的任何链接

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: 使用API​​ 1.3,您可以取回卡所使用的Rect进行绘制:

Rect card = getPeekCardPosition();

So technically, every time you paint the Watchface you can check if this Rect has a Width and Height. 因此,从技术上讲,每次绘制表面时,都可以检查此Rect是否具有宽度和高度。 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: 下一步,可能是在onDraw()和用户已将卡片移除的下一个卡片之间,这将触发一个事件:

onPeekCardPositionUpdate()

Where you can simply invalidate your Watchfaces and re-paint according to the new size of the card. 您可以在其中简单地使您的Watchfaces无效并根据卡的新大小进行重新绘制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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