Android通知 - 自定义收件箱样式(添加行)

时间:2016-07-27 09:35:40

标签: android notifications customization

我想以类似gmail的风格创建一个create expandable通知。通常,使用NotificationCompat.InboxStyle就足够了。但我需要在每一行添加一个图标。非常像Whatsapp。 查看截图 enter image description here 有什么想法如何实现呢?除了使用RemoteViews的自定义布局

1 个答案:

答案 0 :(得分:1)

快速写了一些不好的代码,我到处都有表情符号。

String emoji = new String(Character.toChars(0x1F60A));
Notification noti = new Notification.Builder(this)
            .setContentTitle("5 New mails from " + emoji)
            .setContentText(emoji)
            .setSmallIcon(R.mipmap.ic_launcher)
            .setStyle(new Notification.InboxStyle()
                    .setBigContentTitle(emoji)
                    .addLine(emoji)
                    .addLine(emoji)
                    .setSummaryText(emoji))
            .build();

NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1, noti);
相关问题