1、添加Textiew组件后修改其属性:

  (1)XML文件修改:

android:textColor="#ff0000"    //字体红色android:textSize="24sp"        //字体大小android:textStyle="bold"       //粗体

  (2)修改java代码实现

TextView textView=(TextView)findViewById(R.id.text_view);//取得我们的TextView组件          textView.setTextColor(Color.RED);//设置成红色          textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24f);//设置成24sp          textView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));//加粗  

2、Textiew超链接显示

    (1)网站链接

         xml中添加属性 android:autoLink="web" 即可,颜色自动变为蓝色

  (2)电话号码链接:android:autoLink="phone"

  (3)邮箱链接: android:autoLink="email"

  (4)如果一个string含有多个超链接,则android:autoLink="all"。("\n"代表换行)

<string name="hello">我的博客地址是:http://flysnow.iteye.com    \n我的电话是:400-34534-500\n我的email是12235@163.com android:autoLink="all"

 3、长文本跑马灯形式显示:

        android:ellipsize="marquee"         android:focusable="true"         android:marqueeRepeatLimit="marquee_forever"         android:focusableInTouchMode="true"         android:scrollHorizontally="true"        android:singleLine="true"

4、限制行数

 android:maxLines="2"  

 android:singleLine="true"

 5、让textview为空时,不占空间

 

if(dynamic.getInfo()==null){            holder.dynamic_content.setVisibility(View.GONE);         }else {            holder.dynamic_content.setText(dynamic.getInfo());        }

 

Done!

转载于:https://www.cnblogs.com/xingyyy/p/3252764.html

更多相关文章

  1. android 5.1禁止休眠
  2. Android(安卓)Zxing修改为竖屏扫描,和连续扫描问题
  3. 关于Android(安卓)ListView组件中android:drawSelectorOnTop含义
  4. Android应用程序组件Content Provider的共享数据更新通知机制分
  5. 关于Android(安卓)ListView组件中android:drawSelectorOnTop含义
  6. Android(安卓)隐式调用 intent
  7. 完美解决android Studio打开报错 https://code.google.com/p/and
  8. android如何改变默认横竖屏方向
  9. Android定制之常见问题解决

随机推荐

  1. “百行代码”实现简单的Python分布式爬虫
  2. Redis深入之道:原理解析、场景使用以及视
  3. Docker 的典型应用场景
  4. Redis 21问,你接得住不?
  5. MongoDB,真的是正确的选择吗?
  6. Docker 实用技巧拾遗
  7. Docker的常用镜像及使用方式
  8. json数据与时间戳
  9. 我命由我不由天!如何只让程序运行指定时间
  10. 你以为你很优秀,但却面试屡屡失败?