1.定义不同的style

    <style name="approval_detail_info_style1">
<item name="android:textSize">@dimen/sp13</item>
<item name="android:textColor">#666666</item>
</style> <style name="approval_detail_info_style2">
<item name="android:textSize">@dimen/sp14</item>
<item name="android:textColor">#333333</item>
</style>

2.设置和使用style

        SpannableString styledText = new SpannableString(string);
styledText.setSpan(new TextAppearanceSpan(context, style1), 0, target, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
styledText.setSpan(new TextAppearanceSpan(context, style2), target+1, string.length()-1, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
return styledText;

android textview 设置不同的颜色和大小的更多相关文章

  1. 同一个TextView设置不同的颜色和大小

    //strategy1是一个TextView SpannableStringBuilder builder1 = new SpannableStringBuilder(strategy1.getTex ...

  2. android TextView 设置部分文字背景色和文字颜色

    通过SpannableStringBuilder来实现,它就像html里边的元素改变指定文字的文字颜色或背景色 public class MainActivity extends Activity { ...

  3. android TextView 设置部分文字背景色 和 文字颜色

    通过SpannableStringBuilder来实现,它就像html里边的元素改变指定文字的文字颜色或背景色 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ...

  4. Android TextView 设置行间距

    Android系统中TextView默认显示中文时会比较紧凑,不是很美观.为了让每行保持一定的行间距,可以设置属性android:lineSpacingExtra或android:lineSpacin ...

  5. Android textview 设置不同的字体大小和颜色

    在实际应用中,需要将一个字符串已不同的颜色,字体显示出来.当然完全可以通过不同textview拼接出来.也可以通过一个textview来展示. 步骤如下: 1.定义不同style . 不妨如下定义2个 ...

  6. android TextView 设置字体大小

    package com.example.yanlei.yl4; import android.graphics.Color;import android.os.Bundle;import androi ...

  7. android,在java代码中,如何给textview设置不同的颜色,以及引用color中资源设置颜色

    textV.setTextColor(Color.parseColor("#FF0000")); <pre name="code" class=" ...

  8. TextView设置动态改变颜色

    通过TextView的setTextColor方法进行文本颜色的设置, 这里可以有3种方式进行设置: 第1种:tv.setTextColor(android.graphics.Color.RED);/ ...

  9. Android TextView设置个别字体样式

    TextView进一步深化:       Textview 能够对其文字进行格式化.       通过查询资料,了解到格式化文字的方式主要分为两大类:  第一类:HTML标签格式化文字      代码 ...

随机推荐

  1. SQL Server里的INTERSECT

    在今天的文章里,我想讨论下SQL Server里的INTERSECT设置操作.INTERSECT设置操作彼此交叉2个记录集,返回2个集里列值一样的记录.下图演示了这个概念. INTERSECT与INN ...

  2. python反转字符串(简单方法)及简单的文件操作示例

    Python反转字符串的最简单方法是用切片: >>> a=' >>> print a[::-1] 654321 切片介绍:切片操作符中的第一个数(冒号之前)表示切片 ...

  3. 转载---CSS3实现曲线阴影和翘边阴影

    预备知识 DIV+CSS基础 圆角:border-radius 2D变换:transform:skew && rotate 伪类::before 和 :after 代码 HTML结构代 ...

  4. (C#)WinForm窗体间传值

      1.通过构造函数 特点:传值是单向的(不可以互相传值),实现简单 实现代码如下: 在窗体Form2中 int value1; string value2; public Form2 ( int v ...

  5. 《javascript高级程序设计》读书笔记1

    第二章 在HTML中引用javascript 1.<script>标签的位置:为了避免加载过多的JavaScript的脚本导致浏览器窗口一片空白.现代的web程序一般都把全部的 JavaS ...

  6. 在node.js中使用COOKIE

    node.js中如何向客户端发送COOKIE呢?有如下两个方案: 一.使用response.writeHead,代码示例: //设置过期时间为一分钟 var today = new Date(); v ...

  7. 具有timeout 功能的函数调用

    做项目的时候有时经常会需要一个带有timeout功能的函数调用. 比如从后台读数据并期望在给定时间内返回.借此机会包装了一个简单的C# class, 直接上代码吧. public class Time ...

  8. 重新想象 Windows 8.1 Store Apps (91) - 后台任务的新特性: 下载和上传的新特性, 程序启动前预下载网络资源, 后台任务的其它新特性

    [源码下载] 重新想象 Windows 8.1 Store Apps (91) - 后台任务的新特性: 下载和上传的新特性, 程序启动前预下载网络资源, 后台任务的其它新特性 作者:webabcd 介 ...

  9. Programming in Go (Golang) – Setting up a Mac OS X Development Environment

    http://www.distilnetworks.com/setup-go-golang-ide-for-mac-os-x/#.V1Byrf50yM8 Programming in Go (Gola ...

  10. json format validator

    http://la5u.org/archives/542 http://stedolan.github.io/jq/download/ https://linuxtoy.org/archives/jq ...