【发布时间】:2013-02-28 05:35:48
【问题描述】:
我正在使用 NotificationCompat.Builder 制作一个简单的通知,然后将其添加到通知栏。在运行 API 17 的 AVD 上,可以按预期在通知下拉菜单中看到通知。但在运行 API 13 的 AVD 上,无法看到通知的标题/文本/信息(可能是由于黑色背景下的黑色文本)。
在寻找我的问题的解决方案时,我发现了以下内容:Custom notification colors and text colors 但这似乎只适用于为通知使用自定义布局的情况。
这是我的代码:
private static int notificationId = 1;
private void displayNotification() {
// create an Intent to launch the Show Notification activity
// (when user selects the notification on the status bar)
Intent i = new Intent(this, ShowNotificationActivity.class);
// pass it some value
i.putExtra(ShowNotificationActivity.NOTIF_ID, notificationId);
// wrap it in a PendingIntent
PendingIntent pendingIntent = PendingIntent.getActivity(this, notificationId, i, 0);
// create the notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setContentTitle("This is the Title #" + notificationId);
builder.setContentText("This is the Text");
builder.setContentInfo("This is the Info");
builder.setContentIntent(pendingIntent);
builder.setSmallIcon(android.R.drawable.ic_notification_overlay);
builder.setAutoCancel(true);
Notification notif = builder.build();
// display the notification
NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
nm.notify(notificationId, notif);
notificationId++;
}
我曾希望发布一些屏幕截图,显示 API 17 和 API 13 下的通知下拉,但显然我没有足够的“声誉点”来发布图像。所以我想书面描述就足够了:
在 API 17 下,通知下拉菜单显示通知的图标(红点)、标题和文本。背景颜色为黑色,文字颜色为白色。
在 API 13 下,只有图标(红点)可见。背景颜色是黑色的,我怀疑文字颜色也可能是黑色的。
我怀疑我遗漏了一些明显的东西,但我是新手,希望得到任何指点。
【问题讨论】:
标签: android android-notifications textcolor