SpannableStringBuilder 同时设置setclickspan 和 ForegroundColorSpan出现问题
来源:互联网 发布:工业企业利润数据 编辑:程序博客网 时间:2024/05/20 06:06
借鉴:http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/0305/2535.html这篇文章
项目最初使用的是SpannableString 进行富文本显示,由于需求新增,需要用SpannableStringBuilder来改变显示的字符串。
这时候用setclickspan 和 ForegroundColorSpan会出现字体颜色不是自己设置的情况。
这种情况应该是:setclickspan会有一个链接颜色将ForegroundColorSpan设置的颜色覆盖了(虽然我先设置的setclickspan)所以换成了TextAppearanceSpan,这个span方法可以设置字体的各种颜色
//设置前景色spanspannableString.setSpan(new TextAppearanceSpan(mEditText.getContext(),R.style.SpecialTextAppearance), matcher.start(), end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
<style name="SpecialTextAppearance" parent="@android:style/TextAppearance"> <item name="android:textColor">@color/comment_matcher</item> <item name="android:textColorHighlight">@color/comment_matcher</item> <item name="android:textColorHint">@color/comment_matcher</item> <item name="android:textColorLink">@color/comment_matcher</item><!--链接颜色!!--></style>
0 0
- SpannableStringBuilder 同时设置setclickspan 和 ForegroundColorSpan出现问题
- SpannableString同时设置ClickableSpan和ForegroundColorSpan时ForegroundColorSpan不生效的解决办法
- ForegroundColorSpan 设置textView字体颜色有问题
- Android SpannableStringBuilder设置颜色的问题
- android中为listview同时设置长按项onItemLongClick和点击事件onItemClick出现的问题
- SpannableStringBuilder设置字符串不同颜色和大小
- 关于DO_POWER_INRUSH 和DO_POWER_INRUSH 同时设置问题
- SpannableStringBuilder.setSpan多次设置仅最后一次有效的问题
- 最近网站程序资源逻辑和服务器同时出现问题
- DOM同时设置mouseover与mouseout事件控制元素显示时出现闪烁问题
- SpannableStringBuilder 和 SpannableString(转)
- SpannableStringBuilder 和 SpannableString
- android 字符设置之SpannableStringBuilder
- android SpannableStringBuilder设置自定义字体
- Oracle 客户端配置后,同时再装服务器端出现的无法同时链接远程服务器和本地的问题
- 同时使用Nohttp和环信出现的问题和解决方案
- word与lingoes同时使用出现问题
- SpringMvc+Spring同时扫描出现问题。
- the content of element type must match解决方法
- mysql与oracle 表字段定义比较
- git 命令整理
- 接口与抽象类
- Volly的简单封装
- SpannableStringBuilder 同时设置setclickspan 和 ForegroundColorSpan出现问题
- 数据结构 第五章 数和二叉树
- 数据科学家的修行之路---基本功
- 基于 Python 的数据结构与算法分析学习记录(6-7)—— 树的遍历
- [Leetcode] #334 Increasing Triplet Subsequence
- 【C语言常识】mdk:Inline assembler rules for compiler keywords __asm and asm
- apache kafka系列之在zookeeper中存储结构
- SQL 视图 局部变量 全局变量 条件语句 事务 触发器
- Uncaught TypeError: Cannot read property 'trigger' of undefined(zepto.js)