본문 바로가기
프로그래밍 놀이터/안드로이드, Java

[android] apply different colors on the texts in the textview using xml

by 돼지왕 왕돼지 2013. 10. 21.
반응형


 안드로이드, apply different colors on the texts in the textview using xml

 

[android] apply different colors on the texts in the textview.


<xml>

<string name="various_colors">Here is a text. <![CDATA[<font color="#ff0000">This is red color</font>]]> and <![CDATA[<font color="#00ff00">This is green color</font>]]>. Like it?</string>



<En>

Various text color is not applied directly.

You need to convert the string as a Spanned form with Html.fromHtml function.



<Kr>

다양한 색상이 바로 적용되지 않습니다.

해당 string 을 Html.fromHtml 함수를 이용하여 Spanned 형태로 전환해야 합니다.



<Java Code>

textView.setText( Html.fromHtml( getString( R.string.various_colors ) ) );







반응형

댓글