安卓如何显示大表情符号? (字体大小太大,无法放入缓存) [英] Android. How to display large emoji? (Font size too large to fit in cache)

查看:155
本文介绍了安卓如何显示大表情符号? (字体大小太大,无法放入缓存)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于主持人:我已经找到了类似的问题(一个两个),但它们都不能解决我的问题。请不要将其标记为重复。

For moderators: I already found similar questions (one, two), but none of them solves my problem. Please do not mark as duplicate.

问题:我在Android 7(API 25)上有一台设备,需要在该设备上显示大TextView中的表情符号。如果显示的字体大小低于256个表情符号没有问题,但是显示的字体大小却大于256:

Problem: I have a device on Android 7 (API 25) on which I need to show a large emoji in TextView. If font size below 256 emojis are displayed without problems, but at a size above 256 emojis are not displayed:

ERROR/OpenGLRenderer: Font size to large to fit in cache.

我尝试过的操作:


  • 禁用特定活动的硬件加速

  • 禁用特定TextView的硬件加速

  • 使用以下命令将表情符号转换为轮廓Paint.getTextPath(...)

但是没有任何效果。甚至Paint.getTextPath也不会返回表情符号轮廓(对于纯文本,一切正常)。

But nothing works. Even Paint.getTextPath does not return emojis outline (for plain text everything works).

在模拟器(Android 9,API 28)中,所有表情符号均会显示,但实际设备(Android 7,API 25)-否。

In emulator (Android 9, API 28) all emojis are displayed, but on a real device (Android 7, API 25) - not. This is probably a bug of the android itself.

还有其他显示大表情符号的方法吗?

Are there any other ways to display large emojis?

推荐答案

昨天我自己为此苦了很长时间,我想说的是,如果您不顾一切,可以转到Google Noto Emoji字体库的SVG部分- https://github.com/googlefonts/noto-emoji/tree/master/svg -并下载所需表情符号的SVG文件。然后在Android Studio中执行新建/矢量资产以将SVG文件转换为XML文件,并以任意大小使用它。它甚至比在很大字体大小的路线上使用文字表情符号还要清晰。

Having struggled with this for a long time yesterday myself, I will say that if you get desperate, you can go to the SVG section of Google's Noto Emoji font repo -- https://github.com/googlefonts/noto-emoji/tree/master/svg -- and download the SVG file for the emoji you want. Then in Android Studio do New/Vector Asset to convert the SVG file into an XML file, and use that at whatever size you like. It even looks sharper than going the text-emoji-at-a-very-large-font-size route.

这篇关于安卓如何显示大表情符号? (字体大小太大,无法放入缓存)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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