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

时间:2014-05-31 09:36:00

标签: android android-layout statusbar android-notifications

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

2 个答案:

答案 0 :(得分:4)

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

    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);

答案 1 :(得分:1)

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

Notification noti = new Notification.Builder(this).setStyle(new Notification.BigTextStyle().bigText(longText))