2011-12-12 21 views
4

我想在TextView中寫一行,其中第二個單詞是第一個單詞大小的四分之一。在我的string.xml文件中,我大大小小地使用了它,但它並沒有達到我想要的程度。我也嘗試在main.xml中更改文本大小,但它只允許您在TextEdit中執行一次。有任何想法嗎?如何讓TextView中的文本具有兩種不同的尺寸?

回答

0

嘗試使用HTML類的fromHTML方法。

這樣,你可以使用基本的HTML標籤<font>

4

如果你需要的是用於從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" /> 
相關問題