有时候我们要设置一个TextView里面的字体大小和颜色不一样,等等属性,这时候我们就需要使用Html.fromHtml()格式化字符串,看下面的例子:

String temp = "name:<br /><font color=\"teal\">hello<small>title<b>activeBalance</b></small></font>";TextView textview  = (TextView)view.findViewById(R.id.name); textview.setText(Html.fromHtml(temp)); 

说明:

<br />:表示换行,和“\n”一样。

<small>content</small>:表示小字体。

<font color=\"teal\">content</font>:设置颜色,teal是青色。

<b>content</b>:表示粗体

<u>content</u>:表示下横线

更多格式要求请看:http://www.w3school.com.cn/tags/tag_font.asp这里有很多属性介绍。

更多相关文章

  1. Android(安卓)Material Design 之 BottomNavigationView
  2. 设置Listview item 的分隔线
  3. Android自学之路,ToolBar的使用标题居中颜色设置
  4. TextView设置android:ellipsize="marquee"属性,无法实现跑马灯效
  5. android 分割线渐变色和几种颜色值定义
  6. android 自定义 radiobutton 文字颜色随选中状态而改变
  7. Android(安卓)Snippet
  8. android:layout_below位置到底below到哪儿了?
  9. Android(安卓)自定义 spinner (背景、字体颜色)

随机推荐

  1. android实现圆角矩形
  2. 专家专栏:Android层次化安全架构及核心组
  3. Android之系统自带的文字外观设置及实际
  4. android 牛人必修 ant 编译android工程
  5. 【转】Android(安卓)xml资源文件中@、@an
  6. 《Android/OPhone开发完全讲义》连载(4):And
  7. Android(安卓)的消息队列模型
  8. Android(安卓)Studio更新升级方法
  9. [转]Android的应用程序结构分析:HelloActi
  10. Android(安卓)网络协议