国产探花免费观看_亚洲丰满少妇自慰呻吟_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;
}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 错那县| 门源| 阳东县| 古浪县| 盘山县| 云和县| 石嘴山市| 太保市| 永新县| 曲水县| 嘉义县| 乳源| 五华县| 桃源县| 驻马店市| 鹿邑县| 临朐县| 迁西县| 布拖县| 许昌县| 赣州市| 班戈县| 汉沽区| 乌海市| 博野县| 清河县| 湾仔区| 景宁| 宜宾市| 临颍县| 普兰店市| 济南市| 葫芦岛市| 碌曲县| 抚顺县| 阿瓦提县| 华容县| 栖霞市| 云和县| 油尖旺区| 禄劝|