0

I am having trouble while displaying a string in textview

policyValTv.setText(": " +trimPolicyNo);

Problem is if the trimPolicyNo is a long string, then the textview(policyValTv) displays the whitespace but breaks the line and displays the actual string on the next line. How can I avoid this? I want to display all on one line but not keep singleLine = true. Please help

Aditya Sawant
  • 315
  • 4
  • 13

2 Answers2

1

Try with policyValTv.setText(":\u00A0" +trimPolicyNo); where \u00A0 is the unicode char for non breaking space.

Mimmo Grottoli
  • 5,758
  • 2
  • 17
  • 27
1

Add to your textView in layout XML

 android:maxLines="2"
 android:ellipsize="end"
 android:singleLine="false"
Aown Raza
  • 2,023
  • 13
  • 29