赞
踩
Android开发中会经常遇到TextView自动切行的情况,解决办法有两种:
1,把所有字母、标点、符号、数字全部转换成全角字符,让其与汉字同样占用两个字节。
2,把所有字符,标点,符号换成英文符号。
之前搜索的第二种方法的代码
- public static String StringFilter(String str) throws PatternSyntaxException{
- str=str.replaceAll("【","[").replaceAll("】","]").replaceAll("!","!");//替换中文标号
- String regEx="[『』]"; // 清除掉特殊字符
- Pattern p = Pattern.compile(regEx);
- Matcher m = p.matcher(str);
- return m.replaceAll("").trim();
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。