【发布时间】:2014-07-21 00:48:22
【问题描述】:
我正在尝试使用自定义 RemoteView 创建通知。但是在显示通知时,RemoteView 的底部被裁剪了。通知中只有一半的远程视图可见。谁能告诉我增加通知的高度在安卓中?
【问题讨论】:
标签: android android-layout statusbar android-notifications
我正在尝试使用自定义 RemoteView 创建通知。但是在显示通知时,RemoteView 的底部被裁剪了。通知中只有一半的远程视图可见。谁能告诉我增加通知的高度在安卓中?
【问题讨论】:
标签: android android-layout statusbar android-notifications
首先,Android 上的通知高度限制为 256dp。超过此高度的视图将被剪裁在底部。其次,要创建自定义大通知布局,请像这样使用 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);
【讨论】:
mBuilder.setCustomBigContentView(getComplexNotificationView()); Notification.Builder 有这个设置 bigContentView 的方法
将通知意图的样式设置为bigstyle,
Notification noti = new Notification.Builder(this).setStyle(new Notification.BigTextStyle().bigText(longText))
【讨论】: