Reputation: 4480
I want to write a line in a TextView where the second word is a quarter of the size of the first word. In my string.xml file I used large and small and it did not work to the extent I want it to. I also tried changing the text size in the main.xml, but it only lets you do that once in a TextEdit. Any ideas?
Upvotes: 4
Views: 3643
Reputation: 69396
If what you need is to specify different font sizes for the text in a TextView from XML you can assign a string like this:
<string name="hello"><big><big>Hello Big Text!</big></big>\n<small>Hello small text</small></string>
and use this string in the TextView. Note that the newline is '\n
' instead of <br/>
<TextView
android:id="@+id/text"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:text="@string/hello" />
Upvotes: 4
Reputation: 74790
Take a look at this question: Is it possible to change the text color in a string to multiple colors in Java?
But instead of ForegroundColorSpan
you should use TextAppearanceSpan
or AbsoluteSizeSpan
.
Upvotes: 1