Sver Sver - 9 days ago 5
Android Question

How to scroll ListView to the bottom?

I though this would be a simple task, but apparently there is no way to scroll listview to the bottom. All solutions that I found are using variations of

setSelection(lastItem)
method which only sets selection to last item, but does not scrolls to the bottom of it.

In my case I have a empty listview (with a long empty view header set) and I want to scroll to bottom of it.

So, is there a way to do it?

Edit:

So for those who are interested the working solution is:

getListView().setSelectionFromTop(0, -mHeader.getHeight());


and

getListView().scrollTo(mOffset)


This also works, with right offset (calculated based on current scroll position), but might give you some unexpected results.

Answer

Try using list.scrollTo(0, list.getHeight());

Comments