0

我正在尝试显示小尺寸通知(20dp)。它在 Android 10 和 11 上运行良好,但在小米红米 Android 9 上看起来很糟糕。显示了通知,但在通知下,有30dp的空白,这使得我的通知高度为50dp-60dp。我想知道是因为Android 9或更低版本不支持小尺寸通知,还是因为小米操作系统修改,有没有办法解决这个问题。

这是我用于显示自定义前台通知的代码。

RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.custom_push);
contentView.setImageViewResource(R.id.image, R.drawable.someimage);

Notification notification= new 
NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
.setContent(contentView)
.setCustomContentView(contentView)
.setCustomBigContentView(contentView)
.setPriority(Notification.PRIORITY_DEFAULT)
.setSmallIcon(R.drawable.someimage)
.setColor(Color.LTGRAY)
.setColorized(true)
.setStyle(new androidx.media.app.NotificationCompat.MediaStyle()
.setMediaSession(new MediaSessionCompat(this, "tag").getSessionToken()))
.build();

 startForeground(1, notification);
4

0 回答 0