【发布时间】:2012-08-26 20:44:33
【问题描述】:
我正在向我的应用程序中设置为 API 级别 8 的通知添加两个按钮。问题是这两个按钮显示为两个大的灰色按钮,与其余通知完全不合适。我已经在 Nexus 7 和 Galaxy Nexus 上对其进行了测试。
我见过的所有示例都有漂亮的黑色按钮,例如来电通知: http://www.androidng.com/wp-content/uploads/2012/07/android-jelly-bean-notifications.jpeg
我想这很容易,但今天没有这样的运气。有谁知道我可能在哪里走错了路?下面是我的代码的 sn-p,它使用最新的支持库生成通知。
NotificationManager nm = (NotificationManager) this
.getSystemService(Context.NOTIFICATION_SERVICE);
android.support.v4.app.NotificationCompat.Builder builder = new android.support.v4.app.NotificationCompat.Builder(this);
builder.setContentIntent(contentIntent)
.setSmallIcon(R.drawable.ic_stat_radio)
.setContentTitle(message)
.setTicker(message)
.setPriority(android.support.v4.app.NotificationCompat.PRIORITY_HIGH)
.setWhen(System.currentTimeMillis())
.setAutoCancel(false)
.addAction(android.R.drawable.ic_btn_speak_now, "Play", contentIntent)
.addAction(android.R.drawable.ic_dialog_map, "Stop", contentIntent)
.setContentText(message);
Notification n = builder.build();
//nm.notify(0, n);
startForeground(1, n);
【问题讨论】:
-
你试过用 Notification.Builder 代替 NotificationCompat.Builder
-
是的,仍然存在 :-( 自 Android 1.1 以来我遇到的最奇怪的问题...
-
看起来正在使用 Holo.Light 主题。您能否尝试强制使用 Holo.Dark 主题,或者至少在您自己的主题中继承 Holo.Dark 主题?此外,您可以查看 Holo Everywhere,如果您愿意,它会渗入旧版本的 Android。 holoeverywhere.com
-
或者您正在使用 API 15 中的 android-support.jar?
-
我正在使用支持 lib v4 并使用了 Theme.Black 和 Theme.Holo(深色),但没有变化。好主意!
标签: android android-notifications android-4.2-jelly-bean