this tool class features:
Set part size to TextView
Set some colors for TextView
Set the underline for TextView
Half-width conversion to full-width
Remove special characters or replace all Chinese labels with English labels
/** * Created by Peng on 2015/06/16. * Text Box tool class */ Public class textviewutil { //Set part size to TextView Public Static void setpartialsize(TextView TV,intStartintEndintTextSize) {String s = Tv.gettext (). toString (); Spannable spannable =NewSpannablestring (s); Spannable.setspan (NewAbsolutesizespan (TextSize), start, end, spannable.span_exclusive_exclusive); Tv.settext (spannable); }//Set some color for TextView Public Static void Setpartialcolor(TextView TV,intStartintEndintTextColor) {String s = Tv.gettext (). toString (); Spannable spannable =NewSpannablestring (s); Spannable.setspan (NewForegroundcolorspan (TextColor), start, end, spannable.span_exclusive_exclusive); Tv.settext (spannable); }//Set the underline for TextView Public Static void Setunderline(TextView TV) {if(Tv.gettext ()! =NULL) {String udata = Tv.gettext (). toString (); spannablestring content =NewSpannablestring (Udata); Content.setspan (NewUnderlinespan (),0, Udata.length (),0); Tv.settext (content); Content.setspan (NewUnderlinespan (),0, Udata.length (),0); }Else{Tv.getpaint (). SetFlags (Paint.underline_text_flag); } }//Cancel the TextView underline Public Static void Clearunderline(TextView TV) {Tv.getpaint (). SetFlags (0); }//half angle converted to full angle Public StaticStringTodbc(String input) {Char[] C = Input.tochararray (); for(inti =0; i < c.length; i++) {if(C[i] = =12288) {C[i] = (Char) +;Continue; }if(C[i] >65280&& C[i] <65375) C[i] = (Char) (C[i]-65248); }return NewString (c); }//Remove special characters or replace all Chinese labels with English numerals Public StaticStringReplacecharacter(String str) {str = Str.replaceall ( "" ","["). ReplaceAll ( "" ","]"). ReplaceAll ("! ","!"). ReplaceAll (":",":"). ReplaceAll ("(","("). ReplaceAll ("(",")");//Replace Chinese markingString regEx ="[" "]";//Clear out special charactersPattern p = pattern.compile (regEx); Matcher m = p.matcher (str);returnM.replaceall (""). Trim (); }}
Text Box Tool class--textviewutil