我需要自定义YouTube风格的通知。
但是,我找不到具有该样式的任何应用程序。

它仅使用YouTube吗?

请您指教。

Notification.Builder(context)
                .setContentTitle(" ")
                .setContentText(description)
                .setSmallIcon(R.drawable.notification_icon)
                .setColor(context.getColor(R.color.notification_default_color))
                .setContentIntent(pendingIntent)
                .setAutoCancel(true)
                .setStyle(Notification.DecoratedCustomViewStyle())
                .setGroup(notificationType.summaryGroupKey)
                .setActions(*actions)
                .setCustomContentView(smallView)
                .setCustomBigContentView(expandedView)

最佳答案

我找到了一个方法。

它是自定义的RemoteView和BigPictureStyle的组合。

val builder = Notification.Builder(context)
                .setContentTitle(title)
                .setContentText(description)
                .setSmallIcon(R.drawable.notification_icon)
                .setColor(context.getColor(R.color.notification_default_color))
                .setContentIntent(pendingIntent)
                .setAutoCancel(true)
                .setStyle(Notification.BigPictureStyle().bigPicture(bitmap))
                .setActions(*actions)
                .setCustomContentView(smallView)

自定义的RemoteView具有自己的UI组件,而不是应用程序图标,应用程序名称等。

我可以使它类似于原始的UI。

这是一些技巧。

08-05 07:49
查看更多