简体   繁体   English

Android中的Rich Text Box

[英]Rich Text Box in android

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 ? android中有没有可以用作富文本框的控件,可以处理诸如粗体,斜体等字符的格式并使用字体和颜色?

If anyone having any link or source related to the above information please share it with me. 如果有人拥有与上述信息相关的任何链接或来源,请与我分享。

SpannableString class or HTML.fromHtml() allows you to manipulate different styles in actual string. SpannableString类或HTML.fromHtml()允许您在实际的字符串中操作不同的样式。 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) http://developer.android.com/reference/android/text/SpannableString.html http://developer.android.com/reference/android/text/Html.html#toHtml(android.text.Spanned)

Sample SpannableString and TextView implementation: 示例SpannableStringTextView实现:

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

WebView是我能想到的最接近的,但是除非您希望整个屏幕都是Webview,否则它会变得非常笨拙。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM