Change part of text color within an “EditText” widget

若如初见. 提交于 2019-12-23 09:34:51

问题


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).

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

Thank you! Rodrigo.


回答1:


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

More details: Android: Coloring part of a string using TextView.setText()?



来源:https://stackoverflow.com/questions/6524976/change-part-of-text-color-within-an-edittext-widget

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!