应用样式在TextView的特定字符 [英] Applying style to particular character in textview

查看:149
本文介绍了应用样式在TextView的特定字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我使用的26 的TextView ,这样我可以应用样式根据运行情况特定的字符。
但如果我能能够在特定的字符在TextView中应用样式我可以只使用一个TextView的实现我的目标。

Currently I am using 26 Textview so that I can apply style to particular character depending on runtime situation. But if I can able to apply style on particular character in textview I can achieve my goal using only one textview.

例如。
如果我想使字符'M'冲在以下code。是否有可能实现这一目标?

e.g. If I want to make character 'M' red in following code. Is it possible to achieve this?

    <TextView 
    android:id="@+id/TextView01" 
    android:layout_height="wrap_content" 
    android:textSize="20dip" 
    android:textStyle="bold"
    android:layout_width="15dip" 
    android:text="ABCDEFGHIJKLMNOPQRSTUVWXYZ" 
    android:background="#FFFFFF" 
   android:textColor="#000000"/>`

或其他人比使用26 的TextView 也欢迎更好的选择。

Or anybody have better option than using 26 TextView it also welcome.

推荐答案

您只能使用1的TextView和Html.fromHtml改变颜色()

You can use only 1 textview and change the color by Html.fromHtml()

这篇关于应用样式在TextView的特定字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆