When a button is clicked, I would like the app to smoothly scroll to the bottom of a listview. Currently this is my implementation (kotlin)
listview.post { listview.smoothScrollToPosition(adapter.count - 1) }
However, this does not always work properly: Some list items contain some expandable parts (i.e. view whose visibility can be VISIBLE or GONE), which initially are hidden. When these parts are expanded however, the function sometimes does not scroll to the end, but to a position before the end.
How can I reliably scroll to the end of the listview?