Thursday, 13 October 2011

Android - Multiple lines for the layout

For Android layout, multiple lines of text could be added to the elements.  Here are steps:

1. Create a new variable with the character endOfLine "\n" in the res/values/strings.xml.
For example:
<string name="multiplelines">Line1 \n Line2</string>

2. Refer it in the layout file. For example, for a button:
<Button
    android:id="@+id/start"
    android:text="@string/multiplelines"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent">
</Button>

No comments:

Post a Comment