如何自定义仅折叠的View android通知?

我想在我的应用中显示通知。我正在使用NotificationCompat.BigPictureStyle()。我可以在扩展视图中显示通知。但视图不塌陷。所以我只想修改崩溃通知设计。我已经完成了自定义的notifications_collapsed.xml布局。下面的代码我尝试过,但是没有修改过。

RemoteViews collapsedView = new RemoteViews(context.getPackageName(),R.layout.notification_collapsed);
collapsedView.setTextViewText(R.id.notification_title_collapsed,title);
collapsedView.setImageViewBitmap(R.id.image_view_collapsed,bitmapImage);
Intent activityIntent = new Intent(context,Mainactivity.class);
activityIntent.addflags(Intent.flaG_actIVITY_CLEAR_TOP);
activityIntent.putExtra(ARTICLE_URL,url);
int requestCode = new Random().nextInt();
PendingIntent contentIntent = PendingIntent.getactivity(context,requestCode,activityIntent,0);

NotificationmanagerCompat notificationmanager = NotificationmanagerCompat.from(context);
Notification notification = new NotificationCompat.Builder(context,NOTIFICATION_CHANNEL_ID)
                .setSmallIcon(R.drawable.splash_logo)
                .setContentText(title)
                .setCustomContentView(collapsedView)
                .setStyle(new NotificationCompat.BigPictureStyle()
                        .bigPicture(bitmapImage)
                        .bigLargeIcon(null))
                .setPriority(NotificationCompat.PRIORITY_HIGH)
                .setCategory(NotificationCompat.CATEGORY_MESSAGE)
                .setColor(context.getResources().getcolor(R.color.colorSplash))
                .setContentIntent(contentIntent)
                .setautoCancel(true)
                .build();
ad3344 回答:如何自定义仅折叠的View android通知?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3130626.html

大家都在问