1

I created notification:

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); 

Because its android default notification that may look different on some devices, I would like to know the Title text color, content text color and background color (usually black or white), how can I do this?

DanM
  • 1,530
  • 4
  • 23
  • 44
  • What if you set `Color` by `n.setColor(ARGB);` ? – Mike Dec 24 '14 at 22:09
  • I'm asking because there is a method called `setColor` if you extend Notification.Builder which Returns the `Color`. Maybe that's interesting for you? ;) – Mike Dec 24 '14 at 22:11

2 Answers2

2

Maybe you'll find solution in these posts?

Community
  • 1
  • 1
QArea
  • 4,955
  • 1
  • 12
  • 22
2

According to QArea answer and this answer I have finally defined my TextView on custom notification layout like this for title:

<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"/>

and for default text:

<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"/>

so basically only thing you need to do is add

android:textAppearance="@style/TextAppearance.Compat.Notification.Title"

or

android:textAppearance="@style/TextAppearance.Compat.Notification.Info"

to your TextView

PD: Sorry my english!