gpt4 book ai didi

android - 通知中的滚动文本

转载 作者:行者123 更新时间:2023-11-29 22:01:01 25 4
gpt4 key购买 nike

我有一个包含少量文本的通知,但它仍然很大,无法显示在通知栏中,所以它被缩写了。我发现它是制作自定义通知的唯一解决方案,但对于我正在尝试做的事情来说似乎有点矫枉过正。

我能否使通知滚动文本或扩展通知文本区域以便它显示完整文本而不仅仅是它的前几个词?

我目前通过以下方式调用通知:

private void triggerNotification() {
Notification notification = new Notification(R.drawable.ic_launcher,
"Title", System.currentTimeMillis());
notification.setLatestEventInfo(this, "First text",
"This is the text that gets abberviated with .. when it is too long",
PendingIntent.getActivity(this, 0, new Intent(this,MainActivity.class)
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP),
PendingIntent.FLAG_CANCEL_CURRENT));
notification.flags |= Notification.FLAG_AUTO_CANCEL;
nm.notify(0, notification);


}

最佳答案

在 API 16+ 中,有一个 Notification.Builder允许您添加 subtext 的类可以是多行(如 Gmail notifications )。我不知道 Notification.Builder 是否包含在 the support library 中但我想可能是。你可以检查一下。

但是,如果它不在支持库中并且你必须坚持你的 minSdkVersion,恐怕除了实现你自己的通知版本之外没有办法做你想做的事。


更新:

支持库的最新修订版(2012 年 8 月发布的修订版 10)引入了 Android 4.1 通知样式:BigTextStyle .有一个很好的例子说明如何使用它。查一下here .

关于android - 通知中的滚动文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11939018/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com