在"EditText"中更改部分文字颜色.小部件 [英] Change part of text color within an "EditText" widget

查看:87
本文介绍了在"EditText"中更改部分文字颜色.小部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Android的新手,想知道是否可以仅在EditText小部件中更改部分文本颜色...实际上,我正在制作一个记事本应用程序,例如,写下"bblablabal",然后单击黄色"按钮,并保持黄色书写(之前书写的文本无需更改,就像使用.setTextColor()方法一样).

I'm +- new to android and was wondering if it's possible to change only part of the text color in a EditText widget... Actually i'm making a notepad app where you would be able, for example, to write "bblablabal" and then click on the "yellow" button and keep writing in yellow color (the text written before doesn't have to change, as it does with the .setTextColor() method).

我已经尝试了一些java方法,还尝试了一些没有成功的解决方法...有关如何使其工作的任何想法?

I've tried some of the java methods and also tried some workarounds with no succes... any ideas of how to makes this works ?

谢谢! 罗德里戈.

推荐答案

是的,这是可能的.看看 SpannbleStringBuilder .

Yes, that's possible. Take a look at SpannbleStringBuilder.

更多详细信息: Android:使用TextView.setText()?

这篇关于在"EditText"中更改部分文字颜色.小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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