我使用这样的代码成功地修改了大图片通知
static class MyMultiLineBigPictureStyle extends Notification.BigPictureStyle{
@NonNull
@Override
protected RemoteViews getStandardView(int layoutId) {
RemoteViews ret = super.getStandardView(layoutId);
int id = Resources.getSystem().getIdentifier("text", "id", "android");
ret.setBoolean(id, "setSingleLine", false);
ret.setInt(id, "setLines", 4);
return ret;
}
}
这在api
最佳答案
重写GetStandardView后-无法在API>=24上访问此方法。但如果你打电话
createbigcontentview,android将调用getstandardview方法,您可以得到修改后的remoteview。然后需要将接收到的remoteview设置为自定义大内容视图。
if (Build.VERSION.SDK_INT >= 24) {
try {
RemoteViews remoteView = notificationBuilder.createBigContentView();
if (remoteView != null) {
notificationBuilder.setCustomBigContentView(remoteView);
}
} catch (Throwable t) {
Log.e("","Cannot modify push notification layout.");
}
}