我想在文本更改后检测edittext高度更改。 edittext的高度为wrap_content。如果edittext更改了行号,我将把recyclerview smoothScrolltoposition设置为底部。
我的代码。
var lineNumber: Int = 0;
this.edtMessage.addTextChangedListener(object: TextWatcher {
override fun afterTextChanged(s: Editable?) {
if (lineNumber != edtMessage.lineCount && messages.size > 0)
recyclerView.smoothScrollToPosition(messages.size - 1);
}
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
lineNumber = edtMessage.lineCount;
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
}
});