【问题标题】:How to make YouTube style notification?如何制作 YouTube 风格通知?
【发布时间】:2019-07-01 09:51:05
【问题描述】:

我需要自定义 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)

【问题讨论】:

标签: java android kotlin youtube android-notifications


【解决方案1】:

我找到了办法。

它是自定义 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。

这是一些诡计。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-16
    • 2018-04-09
    相关资源
    最近更新 更多