Thanks to andig for such a wonderful synchron scrollview solution .
But there is a slight lag between both scroll lists during a U-turn.
So, here I am writing an advanced solution to eliminate this delay between scrolling.
I just used the OverScroller class and manually handled the fling event in SyncedScrollView.
You just need to replace SyncedScrollView with the code below. Use other classes from andig solution
import android.content.Context; import android.support.v4.view.ViewCompat; import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.OverScroller; import android.widget.ScrollView; public class SyncedScrollView extends ScrollView implements ScrollNotifier { private ScrollListener scrollListener = null; private OverScroller scroller; private Runnable scrollerTaskRunnable; public SyncedScrollView(Context context) { super(context); init(); } public SyncedScrollView(Context context, AttributeSet attrs) { super(context, attrs); init(); } public SyncedScrollView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } private void init() { scroller = new OverScroller(getContext()); scrollerTaskRunnable = new Runnable() { @Override public void run() { scroller.computeScrollOffset(); smoothScrollTo(0, scroller.getCurrY()); if (!scroller.isFinished()) { SyncedScrollView.this.post(this); } else {
Mitul varmora
source share