首页 > 解决方案 > 你如何在android studio中更改通知的背景颜色?setColor() 方法正在改变文本颜色

问题描述

这是我正在使用的代码。这里的 setColor() 方法改变的是文本颜色而不是背景颜色。在线发布的解决方案对我不起作用。

    Notification notification=new NotificationCompat.Builder(this,CHANNEL_ID_2)
            .setSmallIcon(R.drawable.meditationhd)
            .setLargeIcon(b)
            .setColor(getResources().getColor(R.color.red))
            .setColorized(true)
            .setContentTitle(name)
            .setContentText(singer)
            .setSubText("Beta version")
            .setStyle(new androidx.media.app.NotificationCompat.DecoratedMediaCustomViewStyle())
            .setPriority(NotificationCompat.PRIORITY_HIGH)
            .setOnlyAlertOnce(true)
            .build();

    NotificationManager notificationManager=(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notificationManager.notify(0,notification);

标签: androidandroid-layoutandroid-mediaplayer

解决方案


推荐阅读