Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

two lines in a button text with different sizes

Tags:

android

I found reference by googling that led me to think the following would give me 2 lines of text in a button, first line normal size and second line smaller. However it just wraps all the copy and in the same size. any suggestions please? This is the line in my strings.xml

<string name="teststr"> String I am testing\n <small><small>(with a sub comment)</small></small></string>
like image 712
ron Avatar asked Oct 15 '11 16:10

ron


1 Answers

You can use

myButton.setText(Html.fromHtml("String I am testing<br/><small>(with a sub comment)</small>")); 

or to read the string from your strings.xml

myButton.setText(Html.fromHtml(getString(R.string.teststr)));

Remember that you need to use <br/> instead of \n to get a new line.

like image 84
H9kDroid Avatar answered Oct 01 '22 13:10

H9kDroid