khateeb
khateeb

Reputation: 5469

How to implement timed autoscroll and position markers in RecyclerView?

I have a horizontal RecyclerView in Android. I want to implement an auto scroll feature in it such that it will go to the next view every five seconds. The RecyclerView should also contain circular position markers like in the Amazon Prime Video app which will be on top of the images and will show a different colour for the current view. How do I implement this?

Amazon Prime Video Promo Banners

Upvotes: 2

Views: 3360

Answers (2)

srs
srs

Reputation: 2671

You can use this library for automatic time interval image sliding:--

<ss.com.bannerslider.views.BannerSlider
android:id="@+id/banner_slider1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>

Follow this link for more info

Upvotes: 1

AskNilesh
AskNilesh

Reputation: 69709

you can use TimerTask

A task that can be scheduled for one-time or repeated execution by a Timer.

Timer timer;
public int position =0;
timer = new Timer();
timer.scheduleAtFixedRate(new RemindTask(), 0, 2000); // delay*/

 private class RemindTask extends TimerTask {
int current = viewPager.getCurrentItem();

@Override
public void run() {
    runOnUiThread(new Runnable() {
        public void run() {
           if(position==arraylist.size()){
              position=0;
              position++
           else{
              position++
           }
           recyclerview.getLayoutManager().scrollToPosition(position).

         // or use
          recyclerview.smoothScrollToPosition( position)
        }
    });

}
}

Upvotes: 2

Related Questions