ArcGIS for Android 10.1.1API 中文标注导致程序异常崩溃问题
1、前言
2、解决方案
/** * 文字转换BitMap * @param text * @return */ public static Drawable createMapBitMap(String text) { int size = 50; int height = 60; if(CommonValue.dpilevel==1){ size = 22; height = 30; }else if(CommonValue.dpilevel==2){ size = 50; height = 60; } Paint paint = new Paint(); paint.setColor(Color.BLUE); paint.setTextSize(size); paint.setAntiAlias(true); paint.setTextAlign(Align.LEFT);//位置 float textLength = paint.measureText(text); int width = (int) textLength; Bitmap newb = Bitmap.createBitmap(width*2, height*2, Config.ARGB_8888); Canvas cv = new Canvas(newb); cv.drawColor(Color.parseColor("#00000000")); cv.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG)); cv.drawText(text, width, size, paint); cv.save(Canvas.ALL_SAVE_FLAG);// 保存 cv.restore();// 存储 return new BitmapDrawable(newb); }
3、参考链接
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。