创建循环自动水平滚动视图?视图、水平

由网友(解脱)分享简介:我实现循环自动水平滚动使用Horizo​​ntalScollView。I implement circular Auto Horizontal Scroll using HorizontalScollView.我做了什么:我说孩子的线性布局,包含初始默认子视图假设10 What I did: I added chi...

我实现循环自动水平滚动使用Horizo​​ntalScollView。

I implement circular Auto Horizontal Scroll using HorizontalScollView.

我做了什么:我说孩子的线性布局,包含初始默认子视图假设10

What I did: I added child linear layout, which contain initial default child view let's say 10.

private void startScrolling() {

        handler.postDelayed(new Runnable() {
            public void run() {

                counter = (int) (counter + 10);
                handler.postDelayed(this, 100);

                    viewCount++;

                    if(viewCount == MAX_CHILD) {
                        viewCount = 0;
                        resetViewPosition(0);
                    }

                    mScroller.scrollTo(counter , 0);
            }
        }, 1000L);
    }

现在,一旦开始滚动删除它首先索引视图,并在最后的视图中添加相同的元素。查看继续使用postDelay()实现,因为计时器的滚动。

Now once scrolling start it remove first index view, and add same element at last of view. view keep on scrolling because of timer using postDelay() implementation.

private void resetViewPosition(int viewIndex) {

        View view = llParent.getChildAt(viewIndex);

        Log.v(TAG, "resetViewPosition : "+view.getId()+", "+llParent.getChildCount());
        llParent.removeViewAt(viewIndex);
        llParent.addView(view);
    }

问题:滚动型停止滚动初始元素lenth后滚动,即它不是线性布局,增加新的子扩展

Issue: ScrollView stopped scrolling after scroll initial element lenth, i.e. it's not expanding with addition new child of linear layout.

请建议我什么,我可以在这里做来实现相同的。

Please suggest me what I can do here to implement same.

推荐答案

尝试使用画廊,我想它会正常工作与您的需求。

Try using Gallery, i think it will work fine with your needs

阅读全文

相关推荐

最新文章