I want to show my custom notification by support both small and large layout as screenshots above when user collapse or expand the notification. But the result it shows expanded notification by default. I want to show it as collapsed notification by default and only show expanded notification when user expand it.
Please check my code bellow:
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)
}
Thanks.