I ran into a similar problem. Finally, I fixed the mutable text for the newline character. Here is the code coming.
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);
Sai prasad
source share