Android的磨损 - 通知 - 图像跨度不工作 [英] Android wear - Notification - Image Span is not working

查看:177
本文介绍了Android的磨损 - 通知 - 图像跨度不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在对通知的造型的Andr​​oid磨损通知使用ImageSpan,但它不工作。请告诉我如何程序在通知中使用ImageSpan任何帮助是鸭preciated。下面的示例code我使用。

I am using ImageSpan in Android wear notification for styling in notification, but it's not working. Please tell me the procedure how to use ImageSpan in notifications any help is Appreciated. Following sample code i'm using.

SpannableStringBuilder标题=新SpannableStringBuilder();

SpannableStringBuilder title = new SpannableStringBuilder();

title.setSpan(新ImageSpan(背景下,BMP,ImageSpan.ALIGN_BASELINE),title.length()+ 2,title.length(),Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

title.setSpan(new ImageSpan(context, bmp, ImageSpan.ALIGN_BASELINE),title.length()+2,title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

先谢谢了。

推荐答案

您可以在不使用的通知ImageSpan。

You can not use ImageSpan in Notification.

如果你想显示的图像,也有做两种方法。结果
  1。自定义通知
   这是一个code剪断

If you want to show images, there are two approaches to do it.
1. Custom Notification This is a code snip

      RemoteViews contentViews = new RemoteViews(context.getPackageName(), R.layout.view_notice_common);
        SimpleDateFormat fmt = new SimpleDateFormat("HH:mm");
        contentViews.setTextViewText(R.id.notice_time, fmt.format(Calendar.getInstance().getTime()));
        contentViews.setTextViewText(R.id.notice_title, title);
        contentViews.setTextViewText(R.id.notice_extend_message, content);
        Bitmap smallBitmap = bundle.getParcelable("APP_ICON");
        if (smallBitmap != null) {
            contentViews.setImageViewBitmap(R.id.notice_drawable, smallBitmap);
        } else {
            contentViews.setImageViewResource(R.id.notice_drawable, R.drawable.icon);
        }
        notification.contentView = contentViews;

在这里输入的形象描述

2。采用UNI code数据结果
   code剪断

2. Use Unicode Data
Code snip

  String originalStr = "emoji-" + newString(0x1f602) +newString(0x1f684)+"--over";
  public static final String newString(int codePoint) {
     return new String(Character.toChars(codePoint));
}

然后用originalStr作为标题文本。结果
 

这篇关于Android的磨损 - 通知 - 图像跨度不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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