簡體   English   中英

Android Wear通知出現意外的圖標和背景顏色

[英]Unexpected Icon and background color for Android Wear notification

我正在使用使用NotificationManager發送通知的應用程序。 我設置了一個Android Wear模擬器,並將我的android手機連接到了該模擬器。 我的應用程序生成的通知會顯示在Android Wear模擬器上,但是使用的圖標和顏色不是我所期望的。

該通知使用3個圖標中的1個作為通知圖標,並為3種情況中的每種情況設置不同的LED顏色。 我在手表模擬器上看到的通知使用的是應用程序圖標,而不是我在通知中設置的圖標。 另外,通知的背景顏色是純紅色背景,因此我不確定將其設置為哪種顏色。

如何在手表上獲得與設置的通知圖標匹配的通知,以及如何更改BG顏色?

在下面,粉紅色框是應用程序圖標(而不是我期望的通知圖標)。

觀看通知

通知圖標來自手持式應用程序的res / drawable文件夾。 在res / drawable-hdpi文件夾中是否有一個同名的圖標?

http://developer.android.com/training/wearables/notifications/creating.html

注意:與setBackground()一起使用的位圖對於非滾動背景應具有400x400的分辨率,對於支持視差滾動的背景應具有640x400的分辨率。 將這些位圖圖像放置在掌上電腦應用程序的res / drawable-nodpi目錄中。 將其他可穿戴式通知的非位圖資源(例如與setContentIcon()方法一起使用的那些資源)放置在手持式應用程序的res / drawable-hdpi目錄中。

據我所知,LED的顏色與可穿戴式通知無關。 默認情況下,背景顏色是圖標及其優先級的選擇,如果設置大圖標圖像,它將使用此顏色。 由於大圖標圖像的質量可能很差,因此有另一個呼吁實現這一點。 這是一個完整的示例:

NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
        .setContentTitle("title")
        .setContentText("message")
        // replace the drawable if you want something else
        .setSmallIcon(R.drawable.ic_launcher);

NotificationCompat.WearableExtender extender =
                                    new NotificationCompat.WearableExtender();
Bitmap bg = BitmapFactory.decodeResource(context.getResources(),
                                         R.drawable.background);
// in the line above you can change the background image
extender.setBackground(bg);
builder.extend(extender);

NotificationManagerCompat notificationManager =
                          NotificationManagerCompat.from(context);
notificationManager.notify(42, builder.build());

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM