EditText with ellipses

0

In EditText,

When text can not be displayed completely and you lose focus,

Are there any tags that can be set so that it displays the text with ellipses?

    
asked by anonymous 11.11.2016 / 18:06

2 answers

0
editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
            @Override
            public void onFocusChange(View view, boolean b) {
                if(view.hasFocus()){
                    // se tá com foco, então pôe os "..." no texto
                } else {
                    // se tá sem foco, então mostra o texto inteiro
                }
            }
        });
    
11.11.2016 / 18:39
0

You need to do this in XML

<EditText
        ...
        android:maxLines="1" />

And then you need to put it in Java

String text = edit_text.getText().toString();

if(text.length() > 8){
   edit_text.setText(text.substring(0, 8) + "...");
}

So if it gets bigger than 8 characters it will put the ... in the end

    
11.11.2016 / 18:09