androidnotificationsremoteviewexpandableandroid-4.2-jelly-bean

Android's Expanded Notifications - Both Standard ContentView and custom BigContentView after expansion


I've made a custom RemoteView in JellyBean, as described here, and set it as the bigContentView of a notification.

notification.bigContentView = customNotifView;

I'm trying to have the custom layout placed below the standard contentView after the expansion; something like this.

The problem is that the custom layout overrides the standard contentView after the expansion.

Is there a way to do that?


Solution

  • Much simple solution would look like this

            RemoteViews contentView = new RemoteViews(context.getPackageName(), R.layout.big_notificaiton_layout);
            fillTextViews(profile, contentView);
    
            NotificationCompat.Builder builder = new NotificationCompat.Builder(context, NotificationChannelHelper.Channel.Channel.getId())
                    .setContentIntent(intent)
                    .setContentTitle(context.getResources().getString(R.string.profile_name_is_active, profile.getTitle()))
                    .setStyle(new NotificationCompat.DecoratedCustomViewStyle())
                    .setCustomBigContentView(contentView)
                    .setOngoing(true)
                    .setSmallIcon(R.drawable.icon);
    

    You have to set NotificationCompat.DecoratedCustomViewStyle().