How to bold title in notification?
I have got normal text, but I would like to that my string title will be display as bold.
I have tried sth like below, but it doesn't work.
val sb: Spannable = SpannableString("Bold text")
sb.setSpan(StyleSpan(Typeface.BOLD), 0, 3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
setSmallIcon(R.color.dark_grey) // TODO: replace with an actual icon
setContentTitle(title)
setContentText(content)
setStyle(NotificationCompat.InboxStyle()
.addLine(sb)
.setBigContentTitle(title))
You can apply Spannable
to the title:
val title = "Awesome Title!"
val titleBold: Spannable = SpannableString(title)
sb.setSpan(StyleSpan(Typeface.BOLD), 0, title.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
// ...
notificationBuilder.setContentTitle(titleBold)
// ...