我有机会查看Circle内的大文字。在大我意味着像图像2上的一些短语。
在视图上我将此方法中的字符串拆分为spase“”或字符串中心
IConditionManager
[第一张图片 - when it's not]
[第二张图片 - when it's work]
在onDraw方法中,我将String绘制成一行或两行
public void setmText(CharSequence mText) {
if(mText.length() < 11) {// it can be single line max Chars in line 11
this.isOneTextLine= true;
this.mText = mText;
}else { // it can't be single line
isOneTextLine = false;
String str = mText.toString();
if(str.contains(" ")) {
int index = str.indexOf(" ");
if(index < 11) {
this.mText_second = str.substring(index + 1, str.length());
this.mText = str.substring(0, index);
}else {
if(str.length() - (index+1) > 11 ) {
mText_second = str.substring(str.length()/2, str.length());
this.mText = str.substring(0,str.length()/2) +"-";
}else {
this.mText_second = str.substring(index + 1, str.length());
this.mText = str.substring(0, index);
}
}
}else {
mText_second = str.substring(str.length()/2, str.length());
this.mText = str.substring(0,str.length()/2) +"-";
}
}
}