4/28/2014

[Android] TextView 일부분의 색상을 바꾸기

Easiest way I know is to just use html.
String first = "This word is ";
String next = "<font color='#EE0000'>red</font>";
t.setText(Html.fromHtml(first + next));
But this will require you to rebuild the TextView when (if?) you want to change the color, which could cause a hassle.

Html 코드가 먹는다니 신기하다. 심심해서 찾아봤는데 실제로 될줄이야.



Reference : http://stackoverflow.com/questions/7221930/change-text-color-of-one-word-in-a-textview

댓글 없음:

댓글 쓰기