由网友(later 后来)分享简介:我有一个TextView其中包含文本和HTML属性,如订阅,例如,它是一种化学式为H 2 SO 4 。我怎样才能从TextView的这段文字,而是用订阅(字符串不是显示下标)I have a TextView which contains text with Html attributes like subs...
我有一个TextView其中包含文本和HTML属性,如订阅, 例如,它是一种化学式为H 2 SO 4 。我怎样才能从TextView的这段文字,而是用订阅(字符串不是显示下标)
I have a TextView which contains text with Html attributes like subscription, for example it's a chemical formula H2SO4. How can I get this text from textview, but with subscriptions (String isn't showing the subscript)
在这里你可以看到屏幕截图 https://p.xsw88.cn/allimgs/daicuo/20230903/5901.png
here you can see screenshot https://p.xsw88.cn/allimgs/daicuo/20230903/5901.png
推荐答案
要设置的 ^ h 2 SO 4 在TextView中,使用下标
标记
To set H2SO4 in textview,Use subscript
tag as
textview.setText(Html.fromHtml("H<sub>2</sub>SO<sub>4</sub>"), TextView.BufferType.EDITABLE);
其中,的TextView
是你的TextView的标签。
where textview
is your Textview's tag.
和得到的TextView文本
And get text from textview as
String str = Html.toHtml(textview.getEditableText()).toString();
anothertextview.setText(Html.fromHtml(str));
有关详细信息请参见选择,突出,或文字
相关推荐
最新文章