0

I would like to change the GridView scrolling style to scroll a section (like with ViewPager) instead of one line at a time. Can any one tell me what is the best way to implement this behavior without using any third party library?

trocchietto
  • 2,607
  • 2
  • 23
  • 36
Kobi Moshe
  • 36
  • 1
  • 7

1 Answers1

0

Here there is a post that explain how to use GridView with an horizontal scroll, that as far as I understand is what you are trying to achieve if you want to make it work as a ViewPager

Basically you insert the GridView inside an HorizontalScrollView

 <HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/seatLegendLayout">

        <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="match_parent">

            <LinearLayout
                android:id="@+id/linearLayout_gridtableLayout"
                android:layout_width="900dp"
                android:layout_height="match_parent"
                android:orientation="horizontal">

                <GridView
                    android:id="@+id/gridView1"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_margin="4dp"
                    android:columnWidth="100dp"
                    android:gravity="center"
                    android:numColumns="9"
                    android:horizontalSpacing="1dp"
                    android:scrollbarAlwaysDrawHorizontalTrack="true"
                    android:scrollbarAlwaysDrawVerticalTrack="true"
                    android:scrollbars="horizontal"
                    android:stretchMode="none"
                    android:verticalSpacing="1dp">

                </GridView>


            </LinearLayout>
        </FrameLayout>
    </HorizontalScrollView>
trocchietto
  • 2,607
  • 2
  • 23
  • 36
  • Is that will scroll a numerous of columns instead of one each time ? – Kobi Moshe Jan 27 '18 at 18:06
  • do you want to scroll horizontally or vertically? this is not clear – trocchietto Jan 28 '18 at 09:01
  • I want a grid view paging. Im adding a video which present what i want: https://m.youtube.com/watch?v=jsAWx5zWo-Q (move to the end) I'm not doing that because i want something easier instead of using two adapters – Kobi Moshe Jan 28 '18 at 09:53