create circular Auto Horizontal Scroll View?

喜你入骨 提交于 2019-12-08 07:35:23

问题


I implement circular Auto Horizontal Scroll using HorizontalScollView.

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);
    }

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);
    }

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.


回答1:


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



来源:https://stackoverflow.com/questions/17880250/create-circular-auto-horizontal-scroll-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!