Arcgis for Android 中文乱码只因没有再尝试一步
来源:互联网 发布:武汉汉阳美工 编辑:程序博客网 时间:2024/06/04 13:53
现象
使用Arcgis for Android SDK 开发地图应用时,难免会显示中文,但是当我们把中文显示在地图时,部分手机显示正常,部分手机直接就什么都没有显示,还有一部分显示乱码。
原因
导致乱码的原因部分博客分析一此手机不支持中文字体,当然这没有错,如果 Android 不支持中文字体那系统的中文怎么显示出来的。Arcgis
使用了 OpenGL 进行绘图,在使用 TextSymbol
进行显示文字提供了设置字体的方法,但设置了系统已经有的中文字体就可以显示出来了,那么说明和字体是相关的。
解决办法
方法 1
使用图片代替文字显示
此方法请查看http://blog.csdn.net/u013758734/article/details/41702025
当显示过多内容势必占用内存,所以不太推荐使用此办法。好在我发现第二种办法,不然或许只能用这个办法了。
方法 2 ( 推荐 )
从原因出发
因为 Arcgis 在画 TextSymbol
时没有中文字体,或使用的默认字体不支持中文,所以才导致了这样的问题,我们不能期望Arcgis做些什么,也不能让Android系统在每个终端中加入指定字体。只能自己带个中文字体了。
其它博客写到在使用TextSymbol时使用setFontFamily()设置以下两种字体,因为这两个是支持中文显示的。
String fontFamily = "DroidSansFallback.ttf";if(Build.VERSION.SDK_INT >= 21){ fontFamily = "NotoSansHans-Regular.otf";}
正因为不能保证所有系统都有下面的字体,那么这个问题还是不能得到解决。
废话不多说放大招:
- 下载
DroidSansFallback.ttf"
字体【单击下载】 - 复制下载字体至内存卡
- 使用下面的子类进行字体显示(注意字体在内存卡的路径)
import com.esri.core.symbol.TextSymbol;import org.codehaus.jackson.JsonNode;import java.io.File;/** * Created by canney on 2017/6/11. */public class MyTextSymbol extends TextSymbol { private static final long serialVersionUID = 357217592429086811L; public MyTextSymbol(int size, String text, int color, HorizontalAlignment halign, VerticalAlignment valign) { super(size, text, color, halign, valign); fixedNotSupportChineseBug(); } public MyTextSymbol(int size, String text, int color) { super(size, text, color); fixedNotSupportChineseBug(); } public MyTextSymbol(JsonNode node) { super(node); fixedNotSupportChineseBug(); } public MyTextSymbol(String fontFamily, String text, int color) { super(fontFamily, text, color); fixedNotSupportChineseBug(); } public MyTextSymbol(TextSymbol textSymbol) { super(textSymbol); fixedNotSupportChineseBug(); } /** * 解决中文乱码问题 */ private void fixedNotSupportChineseBug() { //字体在内存卡的路径 String fontFamilyPath = "DroidSansFallback.ttf"; String fontFamily = new File(Environment.getExternalStorageDirectory(), fontFamilyPath).getPath(); setFontFamily(fontFamily); }}
参考:
http://www.cnblogs.com/gis-luq/p/4833361.html
阅读全文
0 0
- Arcgis for Android 中文乱码只因没有再尝试一步
- Arcgis For Android 不支持中文解决方案
- arcgis for android 中文显示问题
- ArcGIS中文label乱码
- Arcgis for Android解决中文字体乱码的问题
- Arcgis for Android多版本中文字体乱码解决方案
- Arcgis for Android解决标注TextSymbol中文字体乱码的问题
- arcgis for android 学习 - (5) 在地图指定位置添加“标记“,并尝试选中它
- 页面乱码,没有中文
- ArcGIS For Android 中文标注不显示解决方案
- ArcGIS FeatureLayer 中文乱码问题
- android 没有焦点可尝试
- [arcgis for android]arcgis for android 定位
- ArcGIS SDE for Oracle 客户端安装配置,oracle中文乱码解决
- ArcGIS for Android
- arcgis for android 学习
- ArcGis for Android定位
- ARCGIS for android
- 使用SQLiteOpenHelper的正确姿势
- JavaScript和TypeScript的单例写法(面向对象)
- Badboy+Jmeter对项目进行测试
- Android 神兵利器Dagger2使用详解(一)基础使用
- Linux C日常笔记
- Arcgis for Android 中文乱码只因没有再尝试一步
- 自定义UTI注册自己的APP
- design-mode2-singleton
- 别人的面试总结
- Zookeeper实例原生API--使用错误权限信息的ZooKeeper会话访问含权限信息的数据节点
- jQuery
- 学习安装python的Scrapy爬虫框架
- C语言指针
- 五、1、正则表达式