I’m trying to create a simple chat layout.
I have a ListView with transcriptMode=”alwaysScroll” and setStackFromBottom(true).
The ListView has a footer with an EditText and a button (It’s a footer because I want it to scroll with the list).
Whenever the user types in the EditText i change the text on the button, using a TextWatcher.
The problem is that when using a physical keyboard, every letter typed scrolls the list to the top, and prevents additional letters to get into the EditText.
It works fine with soft keyboard…
I’ve thought it might be related to the footer being changes calling the adapter to refresh, but it doesn’t seem to be that.
Is this an Android bug or am I missing something?
Thanks.
EDIT:
Another important thing I forgot to add, and is very weird, when typing any letter is scrolls to top, but when deleting characters it works ok, the same afterTextChanged gets called.
Well, looks like I’ve solved it,
The afterTextChanged forced a re-layout in the ListView causing it to jump to top (which should have been jump to bottom because I’ve set stackFromBottom).
Anyway, I’ve switched some views from wrap_content to other alternatives, and switched from using visibility ‘gone’ on hidden views to ‘invisible’ so that the onMeasure wouldn’t have to be called after every letter and it worked.
Hope this helps someone…