I am trying to make a custom notification bar, it works and all but when i test it in lollipop it's displaying the title and content text with white color text, it is good for kitkat because the notification bar is dark but not for lollipop.
How can i make it change to default color or at least detect the theme of the action bar so i can make an if statement to change the color of the text.
<LinearLayout
android:id="@+id/right"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="1">
<ImageView
android:id="@+id/imagenotileft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_launcher"/>
<RelativeLayout
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_width="0dp">
<TextView
android:id="@+id/title"
android:textSize="18sp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:hint="Title Text"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"/>
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:hint="Content Text"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"/>
</RelativeLayout>
<TextView
android:id="@+id/space2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" "
android:layout_toLeftOf="@+id/right2"/>
<RelativeLayout
android:id="@+id/parentRa"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="10dp"
>
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="12:12"
android:text="12:12"
/>
<ImageView
android:id="@+id/imagenotiright"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_action_chat"
android:layout_below="@+id/time"
android:nestedScrollingEnabled="false" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
CODE:
public void CustomNotification(String strtext) {
// Using RemoteViews to bind custom layouts into Notification
RemoteViews remoteViews = new RemoteViews(getPackageName(),
R.layout.customnotification);
// Set Notification Title
String strtitle = getString(R.string.customnotificationtitle);
// Open NotificationView Class on Notification Click
Intent intent = new Intent(this, NotificationView.class);
// Send data to NotificationView Class
intent.putExtra("title", strtitle);
intent.putExtra("text", strtext);
intent.putExtra("String T", "");
//intent.putExtra("Integer C", 0);
// Open NotificationView.java Activity
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
// Set Icon
.setSmallIcon(R.drawable.ic_launcher)
// Set Ticker Message
.setTicker(getString(R.string.customnotificationticker))
// Dismiss Notification
.setAutoCancel(true)
// Set PendingIntent into Notification
.setContentIntent(pIntent)
// Set RemoteViews into Notification
.setContent(remoteViews);
// Locate and set the Image into customnotificationtext.xml ImageViews
remoteViews.setImageViewResource(R.id.imagenotileft,R.drawable.ic_launcher);
remoteViews.setImageViewResource(R.id.imagenotiright,R.mipmap.ic_action_chat);
// Locate and set the Text into customnotificationtext.xml TextViews
remoteViews.setTextViewText(R.id.title,getString(R.string.customnotificationtitle));
remoteViews.setTextViewText(R.id.text, strtext);
// Create Notification Manager
NotificationManager notificationmanager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// Build Notification with Notification Manager
notificationmanager.notify(0, builder.build());
}
I would appreciate any help. Thank you so much.
I am not very sure, but you can try something like this: