Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 如何突出显示通知中每一行的左侧文本大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
目前,我已经实施了多行通知

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 – 如何突出显示通知中每一行的左侧文本所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。