NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this.getApplicationContext()) .setContentIntent(contentIntent) .setSmallicon(R.drawable.ic_notification) .setContentTitle(contentTitle) .setDefaults(Notification.DEFAulT_SOUND) .setTicker(ticker) .setContentText(contentText); // Need BIG vIEw? if (size > 1) { NotificationCompat.InBoxStyle inBoxStyle = new NotificationCompat.InBoxStyle(); // Sets a Title for the InBox style big vIEw inBoxStyle.setBigContentTitle(contentTitle); for (String notificationMessage : notificationMessages) { inBoxStyle.addline(notificationMessage); } mBuilder.setStyle(inBoxStyle); } notificationmanager mnotificationmanager = (notificationmanager) getSystemService(Context.NOTIFICATION_SERVICE); mnotificationmanager.notify(NOTIFICATION_ID,mBuilder.build());
但是,这并不是我想要的.当我看看GMail的实现时,我意识到他们左手边的文字(严成澈)的每一行,都在突出.
我想知道,实现这种效果的技术是什么?我想突出我的股票名称.
解决方法 代码inBoxStyle.addline(notificationMessage);接受CharSequence作为参数,而不是String因此,您可以通过应用Underlinespan轻松实现所需的效果
遵循参考链接:
https://developer.android.com/reference/android/text/style/UnderlineSpan.html
How to set underline text on textview?
快速编辑:
我只是意识到OP提到的亮点而不是下划线但答案仍然是相同的,OP可以选择自定义文本的几种类型的CharacterSpan:
https://developer.android.com/reference/android/text/style/CharacterStyle.html
总结以上是内存溢出为你收集整理的android – 如何突出显示通知中每一行的左侧文本全部内容,希望文章能够帮你解决android – 如何突出显示通知中每一行的左侧文本所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)