①  字体设置:

修改代码 :  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字体设置最少占多少行. 及其 Java String 字符串操作 . .的更多相关文章

  1. android textview字体加粗 Android studio最新水平居中和垂直居中

    android textview字体加粗 Android studio最新水平居中和垂直居中 Android中字体加粗在xml文件中使用android:textStyle=”bold”但是不能将中文设 ...

  2. android TextView多行文本(超过3行)使用ellipsize属性无效问题的解决方法

    这篇文章介绍了android TextView多行文本(超过3行)使用ellipsize属性无效问题的解决方法,有需要的朋友可以参考一下 布局文件中的TextView属性 复制代码代码如下: < ...

  3. android TextView多行文本(超过3行)使用ellipsize="end"属性无效问题的解决方法

    <TextView android:id="@+id/desc" android:layout_width="match_parent" android: ...

  4. android Textview动态设置大小

    import android.app.Activity; //import com.travelzen.tdx.BaseActivity; //import com.travelzen.tdx.uti ...

  5. 【转载】深度解析Android中字体设置

    原文:http://mobile.51cto.com/android-265238.htm 1.在Android XML文件中设置字体 可以采用Android:typeface,例如android:t ...

  6. Android textView 动态设置代码字号大小,支持单位选项 dp,sp or px

    setTextSize(TypedValue.COMPLEX_UNIT_PX,22); //22像素 setTextSize(TypedValue.COMPLEX_UNIT_SP,22); //22S ...

  7. 65、TextView 字体设置不同颜色 --- 未完

    mTextView.setText(Html.fromHtml("教练评论" + "<font color='#b0b0b0'>" + " ...

  8. Android 中文字体的设置方法和使用技巧

    Android TextView字体颜色等样式具体解释连接:http://blog.csdn.net/pcaxb/article/details/47341249 1.使用字体库(自己定义字体的使用) ...

  9. Android 一个TextView中设置多种不同大小的字体,设置超链接

    以前项目中要是遇到这样的UI设计,都是傻不拉唧的分为三个TextView来实现,今天在微信中无意中看了一篇公众号文章,发现原来只要一个TextView就可以搞定啦,人生最悲哀的事情莫过于工作了这么久啦 ...

随机推荐

  1. JoinPoint

    “JoinPoint对象封装了SpringAop中切面方法的信息,在切面方法中添加JoinPoint参数,就可以获取到封装了该方法信息的JoinPoint对象. ” JoinPoint适用于注解和Sc ...

  2. applicationContext.xml 模板

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  3. latex中插入eps文件

    \documentclass{article} \usepackage{graphicx}\usepackage{epstopdf} \begin{document}\begin{figure}  \ ...

  4. ~/.bashrc与/etc/profile的区别

    ~/.bashrc:该文件包含专用于某个用户的bash shell的bash信息,当该用户登录时以及每次打开新的shell时,该文件被读取. /etc/profile中设定的变量(全局)的可以作用于任 ...

  5. linux之常见错误

    在日常开发中,尤其是在Linux中进行操作的时候,经常会碰到各种各样的错误.记录一下,熟能生巧,慢慢参透linux的奥秘 1) 在安装ssl证书的时候,发生certbot命令无法使用的情况 解决方案: ...

  6. myecplise ssh项目配置上遇到的问题

    版本:spring3.1+hib4.1+struts2.1 学习项目使用此版本运行时,总是会遇到各样的错误,在这里做一下记录. 问题1:log4j相关 spring的web项目,执行时报错: 信息: ...

  7. js数据放入缓存,需要再调用

    再贴代码之前先描述下,这个技术应用的场景:一个页面的http请求次数能少点就少,这样大大提高用户体验.所以再一个页面发起一个请求,把所有数据都拿到后储存在缓存里面,你想用的时候再调用出来,这个是非常好 ...

  8. Laravel Providers——服务提供者的注册与启动源码解析

      本文 GitBook 地址: https://www.gitbook.com/book/leoyang90/laravel-source-analysishttps://learnku.com/a ...

  9. [转帖]HTTP 头部解释

    HTTP 头部解释 https://www.cnblogs.com/poissonnotes/p/4844014.html 之前看的太粗了 同事闻起来 referer 才知道自己所知甚少.. ==== ...

  10. [转帖]Centos7 yum安装Chrome浏览器

    Centos7 yum安装Chrome浏览器 https://www.cnblogs.com/ianduin/p/8727333.html以及https://blog.csdn.net/libaine ...