5

Is there any control in android which we can use as a rich text box which can handle formatting of characters such as bold, italic etc. and use fonts and color ?

If anyone having any link or source related to the above information please share it with me.

Avtar Guleria
  • 2,126
  • 3
  • 21
  • 33

3 Answers3

6

SpannableString class or HTML.fromHtml() allows you to manipulate different styles in actual string. See the links below:

http://developer.android.com/reference/android/text/SpannableString.html http://developer.android.com/reference/android/text/Html.html#toHtml(android.text.Spanned)

Nikola Despotoski
  • 49,966
  • 15
  • 119
  • 148
1

Sample SpannableString and TextView implementation:

TextView tv = new TextView;
String text = "String String String String body";
SpannableString spannableStr = new SpannableString(text);
spannableStr.setSpan(new StyleSpan(Typeface.BOLD), 0 , 10, 0);
tv.setText(spannableStr);
CarenRose
  • 1,266
  • 1
  • 12
  • 24
0

WebView is the closest that I can think of, but it is super duper heavy unless you want the entire screen to be a webview.

Prakash Nadar
  • 2,694
  • 1
  • 19
  • 20