如何在android通知中增加remoteview的高度

use*_*647 7 android statusbar android-layout android-notifications

我正在尝试使用自定义RemoteView.But创建通知,当显示通知时,RemoteView的底部正在被裁剪.只有一半的远程视图在通知中可见.可以告诉我有关增加android中通知的高度吗?

Igo*_*sky 5

首先,Android上的通知高度限制为256dp。视图将在超过此高度的底部被剪切。其次,要创建自定义的Big Notification布局,请使用如下所示的RemoteViews:

    NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
    builder.setSmallIcon(R.drawable.ic_notification_icon)

    RemoteViews content = new RemoteViews(this.getPackageName(), R.layout.content);

    Notification notif = builder.build();
    notif.bigContentView = content;
    notificationManager.notify(NOTIFICATION_ID, notif);
Run Code Online (Sandbox Code Playgroud)

  • 解决此问题的方法:mBuilder.setCustomBigContentView(getComplexNotificationView())Notification.Builder具有用于设置bigContentView的此方法。 (6认同)

Sri*_*thi 1

将通知意图的样式设置为bigstyle,

Notification noti = new Notification.Builder(this).setStyle(new Notification.BigTextStyle().bigText(longText)) 
Run Code Online (Sandbox Code Playgroud)

  • 如果我想使用自定义布局来通知怎么办 (2认同)