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

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

本文介绍了创建循环自动水平滚动视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实现循环自动水平滚动使用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

这篇关于创建循环自动水平滚动视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 23:38