I have two gridviews in a linear layout. Here is my XML code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<GridView
android:id="@+id/leftGrid2"
android:layout_width="416dp"
android:layout_height="1078dp"
android:columnWidth="70dp"
android:horizontalSpacing="5dp"
android:numColumns="2"
android:paddingRight="20dp"
android:stretchMode="columnWidth"
android:verticalSpacing="5dp" >
</GridView>
<GridView
android:id="@+id/rightGrid2"
android:layout_width="400dp"
android:layout_height="match_parent"
android:columnWidth="70dp"
android:horizontalSpacing="5dp"
android:numColumns="2"
android:stretchMode="columnWidth"
android:verticalSpacing="5dp" >
</GridView>
</LinearLayout>
How to make these two grid views scroll together or synchronize them ? They have two seperate scrolls when i run my application.
Thanks,
GridView is provided the smoothScrollToPosition(int) method via its AbsLisView parent. This will scroll to the position you desire. Now, you listen for ScrollEvent with the OnScrollListener. Now just tie these together:
Now, this will not! work as expected if your two views are not comparable ie. same content quantity.