国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

Canvas里斷行的方法

2019-11-18 15:58:41
字體:
來源:轉載
供稿:網友

  Canvas里斷行的方法

代碼:--------------------------------------------------------------------------------
/**
* Wrap the text to lines by the specified font, text, maxWidth.
*/
public String[] format(String text, int maxWidth, int lines) {
String[] result = null;
if (lines > 64 lines < 0) {
lines = 64;
}

String[] temPR = new String[lines];
int lineIndex = 0;
if (text != null) {
int len = text.length();
int index0 = 0;
int index1 = 0;
for (; lineIndex < lines; lineIndex++) {
int widthes = 0;
for (index0 = index1; index1 < len; index1++) {
widthes += IMCanvas.textFont.stringWidth("" + text.charAt(index1));
if (widthes > maxWidth) {
break;
}
}
tempR[lineIndex] = new String(text.substring(index0, index1));
if (index1 >= len) {
lineIndex++;
break;
}
}
}
result = new String[lineIndex];
System.arraycopy(tempR, 0, result, 0, lineIndex);
return result;
}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 柘城县| 凌云县| 和林格尔县| 杨浦区| 孙吴县| 旌德县| 黔西县| 安陆市| 章丘市| 南投市| 珠海市| 富裕县| 都匀市| 五河县| 鹰潭市| 嘉峪关市| 应用必备| 新巴尔虎右旗| 郓城县| 富源县| 龙里县| 宜良县| 福贡县| 桓台县| 乌海市| 凤城市| 景德镇市| 黔西| 留坝县| 宽城| 垫江县| 舒城县| 前郭尔| 丘北县| 温宿县| 朝阳县| 甘德县| 双峰县| 平和县| 吕梁市| 驻马店市|