How to let a TextView have multiple lines?

You could have a look at these three xml properties of the TextView:

<TextView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:ellipsize="end"
    android:maxLines="5"
    android:singleLine="false" />

There you can define how many lines the TextView should have, and if there should be displayed dots ("...") when the text exceeds the TextView size.

Also, you can use return inside your strings .xml to start a new line: ("\n")

<string name="intro">This is the first line \n this is a new line.</string>

Here's my first post on stackoverflow...

I think this is the best an simple way to have a multiline textView on android. Here we go:

  1. Write your text in an external editor (ex. Microsoft Word, LibreOffice, etc) with paragraphs and multiple lines.

  2. Open the strings.xml file of your project and create a new string (ex. <string name="my_multiline_textview></string>).

  3. Copy and paste each paragraph from your text inside the tags, putting an \n at the end.

  4. As many \n you put at the end of paragraph, as many lines between them.

  5. Insert a new textView on your layout and associate it with the multiline string created on steps 2, 3 and 4 (android:text="@string/my_multiline_textview").

  6. Go back to the Graphical Layout and see the magic happening :-)

I hope this info can help yo all. See ya.


It sounds like you want to wrap text around a picture, like so:

--------------------
|..........| xxxxxxx
|..Picture.| xxxxxxx
|..........| xxxxxxx
------------ xxxxxxx
xxxxxxxxxxTextxxxxxx
xxxxxxxxxxxxxxxxxxxx

I think the easiest option is to a WebView. However, according to this you can also use image tags in a TextView. I've never tried it myself, but I have used the other tags like so: TextView.setText(Html.fromHtml("<b>some bold text</b> some normal text")) so maybe something similar will work in your situation.