如何在android中创建自定义通知布局? [英] How to create a Custom Notification Layout in android?

查看:191
本文介绍了如何在android中创建自定义通知布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在第一时间在Android中使用通知样式显示通知中的全部内容,或者需要进行自定义布局?

how to show full content in notification at frist time in android with using notification style or need to go for custom layout??

推荐答案

我使用BitTextStyle()在通知中添加了突出显示的文本.

I used BitTextStyle() to add highlighted text in notification.

return new NotificationCompat.Builder(context)
       .setSmallIcon(R.drawable.ic_mono)
       .setContentTitle(title)
       .setContentText(message)
       .setLargeIcon(icon)
       .setColor(ContextCompat.getColor(context, R.color.notification_color))
       .setStyle(new NotificationCompat.BigTextStyle().bigText(title))
       .setStyle(new NotificationCompat.BigTextStyle().bigText(message).setSummaryText("#hashtag"))
       .setShowWhen(true)
       .setAutoCancel(true);

这篇关于如何在android中创建自定义通知布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆