Android smoothScrollBy is behaving badly

I have a ListView that I call smoothScrollBy() on. 95% of the time, smoothScrollTo() behaves as intended. However, there are times when it does not end in the intended place! I confirmed that I give him the same meaning. I notice that smooth scrolling is not so smooth when errors are made, however there are no other tasks that my application performs that I would control.

I'm not quite sure what is going on in the background, but the likely culprit is garbage collection.

95% accuracy is not good enough in this situation. I am going to implement some kind of correction mechanism to make sure the ListView gets to the right place in these cases.

Is there a better way to use smoothScrollBy() , besides just calling view.smoothScrollBy(distance, time); ?

+47
android listview scroll
Sep 29 '11 at 16:18
source share
2 answers

Try a few of them:

Listview has its own scroll mechanism. It scrolls as you add content.

  • Set the list height (android: layout_height) to match_parent or fill_parent.

  • If you assign an adapter to a workflow. Do not perform any user interface actions in the stream.

If this does not solve the problem. Send the code in which you assign the adapter to the list, if any. Or the corresponding code.

Also the xml layout code.

Hope this helps.

+6
Oct 27
source share

sometimes this is due to a synchronization problem. When submissions are added to your list and the time you make

 view.smoothScrollBy(distance, time); 

listview or ui still do not need to be updated. So do this in message flows of views with a certain delay. For example.

 view.postDelayed(new Runnable{ view.smoothScrollBy(distance, time); },1000); 
+5
Jul 26 2018-12-12T00:
source share



All Articles