Weird animation on Gallery when a invalidate is requested from it's children

后端 未结 6 1751
春和景丽
春和景丽 2021-01-14 17:38

This is the adapter of my Gallery on which I display ImageViews (thumb of a page)

I want to load the images ASync (some times this can come from Network), so I did t

6条回答
  •  醉酒成梦
    2021-01-14 18:35

    If you don't get it to work properly, I once made a hack that might help.

    At the end of your doInBackground(), just before you return, do:

    int viewsOnScreen = 3;
    while(viewsOnScreen >= 1){ //adapt the numbers so that they work with your gallery, this is for a gallery with one visible child.
        viewsOnScreen = getLastVisiblePosition() - getFirstVisiblePosition();
        SystemClock.sleep(100);
    }
    

    This will wait with updating your image until you only display one view (or whatever number you specify, the point is you don't have any partial views on screen), causing the 'jump' to go by unnoticed. If your problems also involve jumps to a completely different position in the gallery, I recommend that you check which object you have selected before loading, and after loading you find what position this object is at, and call setSelection() to that position.

    But try all the other solutions first...

提交回复
热议问题