How do I add a newline to a TextView in Android?

Pentium10 picture Pentium10 · May 15, 2010 · Viewed 360.5k times · Source

When I define a TextView in xml, how do I add a new line to it? \n seems not to work.

<TextView
   android:id="@+id/txtTitlevalue"
   android:text="Line1: \n-Line2\n-Line3"
   android:layout_width="54dip"
   android:layout_height="fill_parent"
   android:textSize="11px" />

Answer

Macarse picture Macarse · May 16, 2010

Don't trust the Visual editor. Your code does work in the emu.