如何在scrollView上执行无限循环

时间:2015-11-25 20:59:37

标签: android uiscrollview

我想实现老虎机。我的想法是在我的活动布局中定义三个包含三个ScrollViews的列,并且在每个scrollView内部我使用具有不同ImageView的TableLayout。然后用一个按钮我开始随机滚动..

我的一个列/ ScrollView的示例代码:

<ScrollView
        android:id="@+id/scroll_column_one"
        android:layout_width="100dp"
        android:layout_height="300dp"
        android:layout_centerVertical="true"
        android:layout_toLeftOf="@+id/scroll_column_two"
        android:background="@color/lightgrey"
        android:scrollbars="none">

        <TableLayout
            android:id="@+id/table_slot_icon_column_one"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

            <TableRow>

                <ImageView
                    android:id="@+id/heart_c1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_heart" />
            </TableRow>

            <TableRow>

                <ImageView
                    android:id="@+id/panda_c1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_panda" />
            </TableRow>

            <TableRow>

                <ImageView
                    android:id="@+id/android_os_c1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_android_os" />
            </TableRow>

            <TableRow>

                <ImageView
                    android:id="@+id/paypal_c1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_paypal" />
            </TableRow>

            <TableRow>

                <ImageView
                    android:id="@+id/raspberry_c1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_raspberry" />
            </TableRow>

            <TableRow>

                <ImageView
                    android:id="@+id/star_c1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/ic_star" />
            </TableRow>

        </TableLayout>

    </ScrollView>

我想知道滚动时是否可以循环播放?通过到达ScrollView的底部或顶部,能够永远不会停止scolling操作。

我试图在达到底部时使用自定义类ObservableScrollView进行检测然后返回到顶部,但是在这两个步骤之间UI上有一种中断,它不是很平滑。

        @Override
        public void onScrollEnded(ObservableScrollView scrollView, int x, int y, int oldx, int oldy) {
            scrollColumnOne.smoothScrollTo(0,0);
        }

似乎可以通过listView读取,但我真的想使用ScrollView,至少我现在不想使用外部库。

0 个答案:

没有答案
相关问题