【发布时间】:2016-01-03 03:08:06
【问题描述】:
找不到任何关于如何在 Android 中创建旋转 ScrollView 的信息。我的意思是 ScrollView 在到达最后一个元素时重新启动。
我已经开始实现我自己的自定义 ScrollView,它会在到达底部时滚动到开头。但是我仍然需要注意许多极端情况以使其顺利进行。 (到目前为止只花了几分钟时间)
public class CardScrollView extends ScrollView {
public CardScrollView(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
}
public CardScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CardScrollView(Context context) {
super(context);
}
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
View view = (View) getChildAt(getChildCount()-1);
int diff = (view.getBottom()-(getHeight()+getScrollY()));
if (diff == 0) {
scrollTo(0, -300);
}
super.onScrollChanged(l, t, oldl, oldt);
}
}
我在想应该有很多人在我之前尝试过这样做,但可以在谷歌上找到很多信息。在我花几天时间发展自己的观点之前,谁能指出我正确的方向?
【问题讨论】:
-
不是滚动视图,而是无限画廊:stackoverflow.com/questions/11289448/…。如果不是几天,请在询问之前花一些时间:)
-
我实际上花了几个小时搜索。像我应该使用的词一样的接缝是“循环”而不是“旋转”。
-
AFAIK,如果可能的话,循环滚动视图将很难创建。不过,您可以在滚动视图中拥有无限的网格视图(一列)。试试吧
标签: android scrollview android-scrollview