我创建了通知:
Intent intent = new Intent(this, NotificationReceiver.class);
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
Notification n = new Notification.Builder(this)
.setContentTitle("New mail from " + "test@gmail.com")
.setContentText("Subject")
.setSmallIcon(R.drawable.icon)
.setContentIntent(pIntent)
.setAutoCancel(true)
.addAction(R.drawable.icon, "Call", pIntent)
.addAction(R.drawable.icon, "More", pIntent)
.addAction(R.drawable.icon, "And more", pIntent).build();
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, n);
因为它的android默认通知在某些设备上可能看起来不同,我想知道Title文本颜色,内容文本颜色和背景颜色(通常是黑色或白色),我该怎么做?
答案 0 :(得分:2)
也许你会在这些帖子中找到解决方案?
答案 1 :(得分:0)
根据QArea answer和this answer,我终于在这样的自定义通知布局上定义了TextView
:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.Compat.Notification.Title"
android:textSize="@dimen/subtitle"
android:maxLines="1"
android:text="Notification Title"/>
以及默认文本:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.Compat.Notification.Info"
android:textSize="@dimen/text"
android:maxLines="1"
android:text="Notification description"/>
所以基本上您只需要做的就是添加
android:textAppearance="@style/TextAppearance.Compat.Notification.Title"
或
android:textAppearance="@style/TextAppearance.Compat.Notification.Info"
到您的TextView
PD:对不起,我的英语!