相关疑难解决方法(0)

可以在大文本通知中将扩展通知设置为默认值吗?

我遵循了这个示例代码

Big Text Notifications部分中,他说需要扩展才能看到Big text notification形式,如下图所示:

在此输入图像描述

我不知道我们做不到 set Expanded Notification as default in Big Text Notifications?

知道它的人是否可以,

如果能,

请告诉我怎么做,

谢谢,

notifications android android-notifications android-styles

38
推荐指数
2
解决办法
4万
查看次数

在 Android 中启用展开布局时,如何默认显示带有折叠布局的自定义通知

当用户折叠或展开通知时,我想通过支持小和大布局显示我的自定义通知作为上面的屏幕截图。但结果它默认显示扩展通知。我想默认将其显示为折叠通知,并且仅在用户展开时显示展开的通知。

请检查我的代码如下:

 private fun initCustomNotification() {
    // Get the layouts to use in the custom notification
    val notificationLayout = RemoteViews(packageName, R.layout.custom_notification_small_layout)
    val notificationLayoutExpanded = RemoteViews(packageName, R.layout.custom_notification_large_layout)

    // Apply the layouts to the notification
    customNotificationBuilder = NotificationCompat.Builder(this, CHANNEL_ID)
            .setSmallIcon(R.drawable.dog)
            .setStyle(NotificationCompat.DecoratedCustomViewStyle())
            .setCustomContentView(notificationLayout)
            .setCustomBigContentView(notificationLayoutExpanded)
            .setOngoing(true)
            .setShowWhen(false)
}
Run Code Online (Sandbox Code Playgroud)

谢谢。

layout notifications android android-custom-view kotlin

3
推荐指数
1
解决办法
2165
查看次数