android TextView字体设置最少占多少行. 及其 Java String 字符串操作 . .
2013-11-06 17:18
459 查看
① 字体设置:
修改代码 : GridViewActivity.java
priceTv为 TextView
设置宽度:
priceTv.setMaxWidth(250);
priceTv.setMinWidth(250);
也可:
priceTv.setEms(250);
priceTv.setEms(250);
截取字符串 : 运行结果是 22.000555
上述价格处理有问题
if( p.endsWith(".0")){
p =p.replace(p, p.substring(0, p.length()-2));
} else if(p.endsWith(".00")){
p =p.replace(p, p.substring(0, p.length()-3));
}
修改代码 : GridViewActivity.java
priceTv为 TextView
priceTv.setMaxLines(3); //当多与7个字fu的时候 , 其余字符不显示.. if (name.length()>=7) { name = name.substring(0, 6)+"..."; } priceTv.setMinLines(3);
设置宽度:
priceTv.setMaxWidth(250);
priceTv.setMinWidth(250);
也可:
priceTv.setEms(250);
priceTv.setEms(250);
截取字符串 : 运行结果是 22.000555
public class TestDemo { public static void main(String[] args) { String p = "22.000555000"; while( p.endsWith("0")|| p.endsWith(".")){ p =p.replace(p, p.substring(0, p.length()-1)); } System.out.println(p); } }
上述价格处理有问题
if( p.endsWith(".0")){
p =p.replace(p, p.substring(0, p.length()-2));
} else if(p.endsWith(".00")){
p =p.replace(p, p.substring(0, p.length()-3));
}
相关文章推荐
- android textview字符串指定分段设置字体颜色
- android textview改变部分文字的颜色和string.xml中文字的替换及部分内容设置颜色、字体、超链接、图片
- android Java代码设置textview的字体资源颜色
- Android: TextView 及其子类通过代码和 XML 设置字体大小的存在差异的分析
- Android TextView设置个别字体样式
- Android TextView中文字通过SpannableString来设置超链接、颜色、字体等属性
- Android TextView字体设置
- android TextView的字体颜色设置的多种方法(续)
- 关于Android 中TextView字体设置的那点事
- Android TextView中文字通过SpannableString来设置超链接、颜色、字体等属性
- Android TextView设置不同的颜色字体
- android textview设置字体的行距和字间距
- Android中TextView通过SpannableString设置字体、大小、颜色、样式、超级链接
- Android textview 同时改变字符串中部分字体的颜色与大小
- 【Android笔记-异常-3】数字在TextView中显示一定要先转换为字符串。String.valueOf(数字)
- Android_硬编码设置TextView字体大小
- android-textView-字体的设置
- android同一个TextView设置不同颜色字体
- android TextView的字体颜色设置的多种方法(转)
- Android中的一个TextView中的字体设置不同大小