Add Line Breaks to a TextView Just add a \n to your text. This can be done directly in your layout file, or in a string resource and will cleanly break the text in your TextView to the next line.
When you have a text that's longer than one line, then the TextView will automatically put the text in multiple lines. When you set the layout_width and layout_height as wrap_content or match_parent , then the TextView widget will use all the available space to display the text you specified as its content.
ADD this to your EditText xml code This will automatically moves your text to next line while entering data. this doesn't add \n chars to the string. just breaks the line in the EditText view, which isn't what the OP is asking for.
Don't trust the Visual editor. Your code does work in the emu.
Try:
android:lines="2"
\n
should work.
try System.getProperty("line.separator");
I think this has something to do with your HTM.fromHtml(subTitle)
call: a "\n" doesn't mean bupkis to HTML. Try <br/>
instead of "\n".
First, put this in your textview:
android:maxLines="10"
Then use \n
in the text of your textview.
maxLines makes the TextView be at most this many lines tall. You may choose another number :)
Tried all the above, did some research of my own resulting in the following solution for rendering line feed escape chars:
string = string.replace("\\\n", System.getProperty("line.separator"));
Using the replace method you need to filter escaped linefeeds (e.g. '\\\n'
)
Only then each instance of line feed '\n'
escape chars gets rendered into the actual linefeed
For this example I used a Google Apps Scripting noSQL database (ScriptDb) with JSON formated data.
Cheers :D
Make sure your \n
is in "\n"
for it to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With