how can I display multiple lines of text on a button
If you're trying to add a new line in a layout XML file:
Use
(new line)
android:text="Hi Hello"
If you're trying to add a new line in code, just use '\n', same as in any other text.
If you can't see the second line, it may be that your Button doesn't have enough height. IE, in my case, the layout containing the button had a fixed height that just happened to make my button perfectly display one line of text.
I just tried and it worked:
1) Define in ../res/values/strings.xml:
<string name="multilines">Line1Line1\nLine2Line2</string>
2) Refer it in the layout file:
<Button
android:id="@+id/btn_multilines"
android:text="@string/multilines"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
</Button>
In case you want to do that programmaticaly you can use System.getProperty("line.separator")
in the string to change lines.
Like this:
String mybuttontext=line1+System.getProperty("line.separator")+line2;
and then set this String as buttons text.