I have some text that have more than one paragraph (using \"\\n\") and want to put a spacing between the paragraphs, but without using \"\\n\\n\". But the text from the same par
I have faced a similar problem. Finally, I fixed with spanable text for newline character. Here is the code goes.
String text ="Lorem ipsum dolor sit amet, End of first line.\nBegining of the second line, Aenean justo mi, faucibus eu suscipit id, finibus gravida quam. End of Second Line.\nBegining of the third line, Aliquam ac diam tempus, pharetra nibh at, imperdiet diam. End of Third Line.\n Begining of the fourth line, Fusce placerat erat dolor, id tristique lacus gravida ac. End of Fourth Line.\nBegining of the Fifth line, Sed id molestie est, sed elementum lectus. End of Fifth Line.\n";
text = text.replace("\n","\n\0");
Spannable spannable = new SpannableString(text);
for (int i = 0; i < text.length()-1; i++) {
if (text.charAt(i) == '\n') {
spannable.setSpan(new RelativeSizeSpan(1.5f), i+1, i+2, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
mTextMessage.setText(spannable, TextView.BufferType.SPANNABLE);