Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set text inside TextView to be in two lines?

Is there any way to programmatically set text in TextView to be in two lines ?

like image 959
Damir Avatar asked Oct 17 '11 09:10

Damir


2 Answers

Type \n for a new line

This will be\ntwo lines

will look like

This will be
two lines

Also, be sure that the TextViews setsingleline() isn't set to true

like image 50
drewi Avatar answered Nov 02 '22 00:11

drewi


TextView tv = new TextView(this);
tv.setText("First Line \n this is Second Line");
setContentView(tv);
like image 28
MKJParekh Avatar answered Nov 01 '22 23:11

MKJParekh