0

I want to do something like picture below I want to write the text in the Edittext hint and if it can't show full text write three points(...) after it I'd like it to be in just one line of code.

it's a edit text hint in android

bpeterson76
  • 12,918
  • 5
  • 49
  • 82
  • check this link http://hackingui.com/front-end/a-pure-css-solution-for-multiline-text-truncation/ also http://stackoverflow.com/questions/3597550/ideal-method-to-truncate-a-string-with-ellipsis – Karthik Ganesan Feb 22 '17 at 19:56
  • Possible duplicate of [How can I show ellipses on my TextView if it is greater than the 1 line?](http://stackoverflow.com/questions/6393487/how-can-i-show-ellipses-on-my-textview-if-it-is-greater-than-the-1-line) – bpeterson76 Feb 22 '17 at 22:26

2 Answers2

0

You can check the length and if is longer than , then truncate the text....

if (myTextView.length >15){

 myTextView.setText(myTextView.getText().substring(0,10)+"...");
}
ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97
0

Try setting the following XML attributes on your EditText:

android:maxLines="1"
android:ellipsize="end"
aneurinc
  • 1,238
  • 12
  • 20