flickerfacebook-wallandroid-scrollview

Android ScrollView ScrollTo and flicker


I note that the screen will flickers whenever scrollTo is called. What I wanted to achieve is to make sure the ScrollView content remain at the same position on the screen while data being added into top/bottom of the ScrollView.

My idea is to create a customized ScrollView which loads additional data when user scroll up or scroll down, something that similar on Facebook wall.


Solution

  • After many trials and error and I realized that the thing that contributes to the flicker is the scrolling being implemented in a Runnable. Initially the Y coordinate can't be found until the screen finish rendered. I then changed the logic to calculate the height of items that added into ScrollView (as the height of the item is known) and call the scrollTo in the next step. This approach eliminates the flicker effect. Cheers.