New line (\n) not Supporting in android?

21,032

Solution 1

I think you are new into android development like me. It's really easy to do...

You just have to do this:

editText.setText("Hi,\nHow are you?");

Solution 2

It's "\n" - a backslash, not a forward slash.

See this related question for more information about how to make a multiline text view look right.

Solution 3

In your case, replace "/n" and with "\n" and also if you need more then one EditText, then you must edit properties of EditText as below:

android:singleLine="false" 
android:MaxLines = "5"

if you know the exact number of lines.

Share:
21,032
vinothp
Author by

vinothp

Do what you like. Believe in what you do. Young and energetic individual with great passion on Mobile Application Development. Currently working as a full time mobile application developer for Android and iOS. In free time working on personal projects as well. My First Personal App - Location Plotter/ House Viewing

Updated on May 11, 2020

Comments

  • vinothp
    vinothp about 4 years

    I am trying to split the single string in to two lines using \n in android but it shows as it is with \n too. I am expecting below,

    String new = "Hi, How are you";
    

    In EditText box I need,

    Hi,
    
    How are you
    

    I know its simple question but I couldn't find a solution.