我想在一个TextView中写一行文本,其中第二个单词的大小是第一个单词的四分之一。 我在我的string.xml文件中使用了large和small,但是它并没有达到我想要的效果。 我还尝试在main.xml中更改文本大小,但是它只能在TextEdit中进行一次。 有什么建议吗?
如果你需要从XML中指定TextView中文本的不同字体大小,你可以分配类似这样的字符串:
<string name="hello"><big><big>Hello Big Text!</big></big>\n<small>Hello small text</small></string>
在TextView中使用此字符串。请注意,换行符为'\n
',而不是<br/>
<TextView
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="@string/hello" />
TextAppearanceSpan
}}或{{link3:AbsoluteSizeSpan
}},而不是ForegroundColorSpan
。