Search code examples
androidnewlinetextview

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


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 -\nLine2"
   android:layout_width="54dip"
   android:layout_height="fill_parent"
   android:textSize="11px" />

Solution

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