Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I display <ruby> element in TextView?

mTextView.setText(Html.fromHtml("26<ruby>日<rt>にち</rt></ruby>から"));

But Html.fromHtml doesn't support ruby element well. <rt> elements will be omitted in the textview. Is there any workaround? I have a list of such TextView, so WebView is inefficient.

Edit: I tried WebView, and it worked better than I thought. Be careful with encodings.

like image 786
Zen Avatar asked Jan 27 '26 20:01

Zen


1 Answers

Android seems support the following HTML tags to be rendered on TextView.

<a href=”…”> <b>,  <big>, <blockquote>, <br>, <cite>, <dfn>
<div align=”…”>,  <em>, <font size=”…” color=”…” face=”…”>
<h1>,  <h2>, <h3>, <h4>,  <h5>, <h6>
<i>,  <img src=”…”>,  <p>, <small>
<strike>,  <strong>, <sub>, <sup>, <tt>, <u>

So ruby tag is not supported in here .

  • Is there any workaround? For your ruby -NO
like image 131
IntelliJ Amiya Avatar answered Jan 30 '26 12:01

IntelliJ Amiya



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!