RecyclerVIew auto scroll to display all the elements as in News Feed etc.,

前端 未结 7 728
慢半拍i
慢半拍i 2020-12-14 11:47

How to auto scroll RecyclerView smoothly so that user can see all the elements of the RecyclerView and scroll again from the start - as in News Feed etc.

<
7条回答
  •  误落风尘
    2020-12-14 12:20

    I think this is the best solution for this.

        final int speedScroll = 150;
        final Handler handler = new Handler();
        final Runnable runnable = new Runnable() {
            int count = 0;
            @Override
            public void run() {
                if(count < list.size()){
                    recyclerView.scrollToPosition(count++);
                    handler.postDelayed(this,speedScroll);
                }
    
    
            }
        };
    
        handler.postDelayed(runnable,speedScroll);
    

提交回复
热议问题