Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EditText - On word wrap (new line) listener

Is there a way to listen on an EditText for the scenario where the text inserted is being wraped? (standard new line listener won't work since there is actually no real "/n" string on the edittext).

Maybe a listener on the height of the edit text changing?

like image 732
Urbanleg Avatar asked Oct 18 '25 18:10

Urbanleg


1 Answers

Try this. Depending on the number of lines you know if there is text wrapping or not.

edittext.addTextChangedListener(new TextWatcher() {

        public void afterTextChanged(Editable s) {}

        public void beforeTextChanged(CharSequence s, int s, int c, int a) {}

        public void onTextChanged(CharSequence s, int s, int b, int c) {
            Log.d("TESTING", " LINES = " + edittext.getLineCount());
        }
    });
like image 189
Tony Avatar answered Oct 20 '25 08:10

Tony



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!