自定义通知布局提供了不必要的余量

Sha*_*kar 6 notifications android remoteview

我正在为我的应用程序创建自定义通知布局。

NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NOTIFICATION_CHANNEL_ID)
            .setSmallIcon(R.drawable.ic_notification_icon)
            .setPriority(NotificationCompat.PRIORITY_DEFAULT)
            .setCustomContentView(notificationLayoutCollapsed)
            .setOngoing(playing)
            .setCustomBigContentView(notificationLayoutExpanded)
            .setStyle(new NotificationCompat.DecoratedCustomViewStyle())
            .setContentIntent(pendingIntent);
Run Code Online (Sandbox Code Playgroud)



我的通知布局没有内部填充或边距,但它显示通知的边距(蓝色通知周围的白色粗边框)。

请提出解决此问题的方案。

- - 回答 - - -

罪魁祸首是以下这一行

.setStyle(new NotificationCompat.DecoratedCustomViewStyle())
Run Code Online (Sandbox Code Playgroud)

DecoratedCustomViewStyle 为通知提供边框