Search code examples
androidimageandroid-listviewimage-scaling

ListView Scroll To Bottom with AsynTask on Image


Problem: ListView Cannot Scroll To Bottom when Image(s) are loaded using AsynTask.

Details: I want to scroll the listView to bottom when user opens the listView. The listview contains both images and text. For better memory managemt, i am using the method suggested here, which shows a small icon when the bitmap is loading.

In order to scroll to bottom, I used"

`listview.setStackFromBottom(true);`

and:

listView.setSelection(adapter.getCount()-1);

However, for images listview, it just can't scroll to bottom. Is there any solutions for this issue?

enter image description here


Solution

  • I finally figure out the root of the problem. When you are loading images in listView using "AsyncTask", you need to use

    listView.setOverScrollMode(View.OVER_SCROLL_IF_CONTENT_SCROLLS);
    

    My listview cannot scroll to the bottom as i set

    listView.setOverScrollMode(View.OVER_SCROLL_NEVER);
    

    which leads to the problem discussed above.