I'm trying to create some custom notifications for my app.
Usually collapsed view layouts are limited to 64 dp, and expanded view layouts are limited to 256 dp.
Although I considered these restrictions, it seems that the notification is cut off on several phones as you can see in the screenshots below. I did some research on that because I thought there are also restrictions depending on different manufacturers or UIs, but couldn't find anything.
That's how it is implemented:
// 64dp is set for height
val collapsedView = RemoteViews(packageName, R.layout.custom_notification_collapsed)
// 256dp is set for height
val expandedView = RemoteViews(packageName, R.layout.custom_notification_expanded)
val customNotification: Notification = NotificationCompat.Builder(this, "default")
.setSmallIcon(R.drawable.ic_launcher_background)
.addAction(R.drawable.ic_map, "Personal", PendingIntent.getService(this, 0, personalIntent, PendingIntent.FLAG_UPDATE_CURRENT))
.addAction(R.drawable.ic_map, "Business", PendingIntent.getService(this, 0, businessIntent, PendingIntent.FLAG_UPDATE_CURRENT))
.addAction(R.drawable.ic_map, "Work", PendingIntent.getService(this, 0, businessIntent, PendingIntent.FLAG_UPDATE_CURRENT))
.setColor(Color.parseColor("#00D8FF"))
.setStyle(NotificationCompat.DecoratedCustomViewStyle())
.setCustomContentView(collapsedView)
.setCustomBigContentView(expandedView)
.build()
notificationManager.notify(4, customNotification)
Here's the result:
Now the questions are: Did I fail the implementation somehow? If not, is there a way to figure out the max. notification height for a current phone programmatically?