我正在开发一个Android音乐应用,我正在尝试将浅色状态栏上的TextView
和图标颜色更改为黑色,将深色状态栏上的 private int getNotificationIcon() {
boolean useWhiteIcon = (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M);
return useWhiteIcon ? R.layout.layout_notification_small: R.layout.layout_notification_small_black;
}
public void showNotification() {
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
String CHANNEL_ID = "controls_channel_id";
String CHANNEL_NAME = "controls_channel";
NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH);
channel.setSound(null,null);
channel.enableVibration(false);
notificationManager.createNotificationChannel(channel);
notificationBuilder = new NotificationCompat.Builder(getApplicationContext())
.setChannelId(CHANNEL_ID)
.setContentText("placeholder")
.setContentTitle("placeholder");
}else{
notificationBuilder = new NotificationCompat.Builder(
getApplicationContext());
}
Track track = tracks.get(trackIndex);
RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.layout_notification);
remoteViews.setTextViewText(R.id.tvTitle, track.getTitle());
RemoteViews remoteSmallViews= new RemoteViews(getPackageName(),getNotificationIcon());
remoteSmallViews.setTextViewText(R.id.tvTitle, track.getTitle());
和图标颜色更改为白色(例如Instagram),无法做到这一点。有一些方法可以检查android版本,但对我没有帮助。我必须检查一下我认为的主题。无论如何,我该怎么办?
Here is a print screen of how the notification is
.project