4

Anyone know how to get the new paragraph (\n or enter) spacing height for an edit text?

What I'm trying to do: I would like to draw a line below all the text and make a big editing area like a notepad. At the moment, I'm able to get the line spacing through LineSpacingExtra, LineHeight, LineCount. However, none of this seems to allow me to get/set the new paragraph spacing. Any idea?

Click to see screen shot

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • TextView isn't really designed to display multiple paragraphs of text. – OneCricketeer Mar 18 '16 at 07:15
  • When i tested my code in pre-lollipop, it works perfectly and I found that it is working perfectly. And this issues is related to [a bug posted here](https://code.google.com/p/android/issues/detail?id=77941). By the way, I added LineSpacingMultiplier and ExtraLineSpacing for the edit text shown above. – Chean Siong Mar 18 '16 at 09:48

2 Answers2

0

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

string = string.replaceAll("\\\n", System.getProperty("line.separator"));
  1. Using the replace method you need to filter escaped linefeeds (e.g. '\\n')

  2. Only then each instance of line feed '\n' escape chars gets rendered into the actual linefeed

Aditya Vyas-Lakhan
  • 13,409
  • 16
  • 61
  • 96
Palani kumar
  • 119
  • 1
  • 10
0

It is not an issue and this issues is related to a bug posted here. By the way, I added LineSpacingMultiplier and ExtraLineSpacing for the edit text shown above.