一个文本框2种字体大小、颜色

第一种方法:

        //设置两种字体大小
        Spannable WordtoSpan = new SpannableString(codeMemoTV.getText().toString());
        WordtoSpan.setSpan(new AbsoluteSizeSpan((int) DimensionUtil.convertDpToPixel(18, this)), 0, 8, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        codeMemoTV.setText(WordtoSpan);

        //设置两种字体颜色和大小
        Spannable WordtoSpan1 = new SpannableString("好友成交额6255.50元");
        WordtoSpan1.setSpan(new AbsoluteSizeSpan((int) DimensionUtil.convertDpToPixel(18, this)), 5, 8, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        WordtoSpan1.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.black)), 5, 8, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        codeMemoTV.setText(WordtoSpan1);

或者:

msgTV.setText(Html.fromHtml(String.format("%s出价 <font color=\"#f06c55\">%.0f</font>元", item.getIsPerPrice() , item.getBidPrice())));

效果图:

时间: 2024-07-28 16:19:08

一个文本框2种字体大小、颜色的相关文章

iOS一个UILabel 显示两种字体和颜色

UILabel infoLabel3; 以空格为截断点.查找空格的位置,然后建立 NSRang.当然也可以自己指定范围. NSRange range; range = [infoLabel3.text rangeOfString:@" "]; if (range.location != NSNotFound) { NSLog(@"found at location = %lu, length = %lu",(unsigned long)range.location,

AttributedString - 富文本(不同字体大小颜色,下划线中划线)

1 #import "ViewController.h" 2 3 @interface ViewController () 4 5 @end 6 7 @implementation ViewController 8 9 - (void)viewDidLoad { 10 [super viewDidLoad]; 11 // Do any additional setup after loading the view, typically from a nib. 12 13 NSArray

spinner 设置文本框中的字体颜色

onItemSelected(AdapterView parent, View v, int position, long id) { TextView v1 = (TextView)v; v1.setTextColor(Color.WHITE); //可以随意设置自己要的颜色值 } 本文转自:http://bbs.csdn.net/topics/350049938 spinner 设置文本框中的字体颜色

js 判断一个文本框是否获得焦点

1.js 判断一个文本框是否获得焦点 // 可以用document.activeElement判断 // document.activeElement表示当前活动的元素 // 查找你要判断的文本框 var myInput = document.getElementById('myInput'); if (myInput == document.activeElement) {     alert('获取焦点'); } else {     alert('未获取焦点'); } 2.文本框获取焦点后

用javascript实现控制一个文本框的输入字数限制,超出字数限制文本框飘红显示-面试题

用javascript实现控制一个文本框的输入字数限制,超出字数限制文本框飘红显示. html <textarea name="" id="text" cols="30" rows="10" maxLength=10></textarea><br> <span id="span"></span> javascript var str = docum

javascript 获取光标所选中的内容并插入到另一个文本框中(兼容ie和ff)

项目中正好用到 做下笔记方便以后查找 ie获取光标的位置使用document.selection.createRange() 火狐下使用document.getElementById(id).selectionStart 和 document.getElementById(id).selectionEnd 假设我们要获得id为txt的Textarea元素里面光标所选择的内容 首先创建一个获得光标所选内容的函数(参数:火狐下需要Dom元素 select_field=document.getElem

16 如何使一个文本框只能接受数字

(1) 使用NumericUpDown (2) 处理KeyPress 按钮 (3) 处理Text_Changed 事件 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; usin

JS复选框向一个文本框中传值的多选效果

选择一个复选框,那么这个复选框的值就传到一个文本框中,如果这个文本框里有了就不用加了,没有则加.如果取消选择,则从文本框中取掉传的值.中间以“,”分隔,最后结尾没有“,”分隔符. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns=&q

弹框(AlertDialog)和提示信息Toast字体大小颜色设置

一.AlertDialog: AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("温馨提示"); builder.setMessage("是否进行下一个病人?"); builder.setPositiveButton("是", new DialogInterface.OnClickListener() { @Override