如何写“权力”和Java或Android中显示的一些文本? [英] How to write the "to the power" and some text like as shown in Java or Android?

查看:141
本文介绍了如何写“权力”和Java或Android中显示的一些文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如下图所示,是否可以编写代码在Android或Java中写入电源?

As in the images shown below, is it possible to write code to write "to the power" in Android or Java?

推荐答案

类似:

TextView t = (TextView) findViewById(R.id.text);
t.setText(Html.fromHtml("7<sup>2</sup>"));

根据他们常见问题解答中的Android文档,您始终可以使用字符串资源执行此操作,但如果您你必须确保TextView正在使用Spannable存储(例如,如果它是一个EditText,则总是如此)。

According to Android documentation on their FAQ, you can always do this using a string resource, but if you do it on the fly you must make sure the TextView is using Spannable storage (always true if it's an EditText for example).

请参阅选择,突出显示或设置样式部分 Android常见任务中的文字。

See Selecting, Highlighting, or Styling Portions of Text in the Android Common Tasks.

这篇关于如何写“权力”和Java或Android中显示的一些文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆