Rich Text Box in android

后端 未结 3 1708
眼角桃花
眼角桃花 2021-01-06 06:30

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

相关标签:
3条回答
  • 2021-01-06 07:06

    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);
    
    0 讨论(0)
  • 2021-01-06 07:11

    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.

    0 讨论(0)
  • 2021-01-06 07:13

    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)

    0 讨论(0)
提交回复
热议问题