views:

847

answers:

3

I'm looking for a simple way in Android to add a text to a button that is displayed in 2 (or more) lines. E.g. A bold and big heading in the first line and a small description in the second line.

Is it possible or have I use a TextView or something similar?

+3  A: 

Have you tried modifying your text property to something like "line1\nline2" ?

Rigo Vides
Yes, tried it. The text is displayed in a single line. Instead of the line break a space is shown.
André
Yeah, after setting setSingleLine(false), the \n is interpreted as line break. But that does not solve the problem of having a bigger heading and a smaller description below.
André
+2  A: 

Have you set android:singleLine="false"?

Erik B
See the last comment of the previous answer. With setSingleLine(false) and \n I got he two lines. But now the formatting (bigger heading and smaller description) is open.
André
+1  A: 

You could use the Html.fromHtml function, and use tags like <br> and <small>. More info here: http://stackoverflow.com/questions/1529068/android-is-it-possible-to-have-multiple-styles-inside-a-textview If you want bigger fonts, just set the android:textSize value in your xml layout.

janfsd
Thank you, that works like expected.
André