SoFunction
Updated on 2025-04-10

Detailed explanation of how to use RollViewPager unlimited carousel

Supports infinite loops. Playback is paused when touched until a delay cycle is over to continue playing. It looks like this. The indicator can be a point, a number, a custom, and the position can also be changed. .

Main operation process:

1. Import packages in gradle:

compile ':rollviewpager:1.2.9'

2. Set playback time interval, transparency, indicator (indicators can be the default origin, number, or custom pictures)

3. Set up the adapter. This demo is StaticPagerAdapter. This is relatively simple and uses more. If you need it, you can see the github source code.

The main thing is to set pictures, the number of pictures, etc.

MainActivity:

package .;

import ;
import ;
import .;
import ;
import ;
import ;
import ;
import ;

import ;
import ;
import ;

public class MainActivity extends AppCompatActivity {

  private RollPagerView mRollViewPager;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    (savedInstanceState);
    setContentView(.activity_main);

    mRollViewPager = (RollPagerView) findViewById(.roll_view_pager);

    //Set playback time interval    (1000);
    //Set transparency    (500);
    //Set the adapter    (new TestNormalAdapter());

    //Set indicators (sequence)    //Custom indicator picture    //Set the dot indicator color    //Set text indicator    //Hide indicator    //(new IconHintView(this, .point_focus, .point_normal));
    (new ColorPointHintView(this, ,));
    //(new TextHintView(this));
    //(null);
  }

  private class TestNormalAdapter extends StaticPagerAdapter {
    private int[] imgs = {
        .img1,
        .img2,
        .img3,
        .img4,
    };


    @Override
    public View getView(ViewGroup container, int position) {
      ImageView view = new ImageView(());
      (imgs[position]);
      (.CENTER_CROP);
      (new (.MATCH_PARENT, .MATCH_PARENT));
      return view;
    }


    @Override
    public int getCount() {
      return ;
    }
  }

}

activity_main:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:andro
    xmlns:app="/apk/res-auto"
    xmlns:tools="/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

 <
  android:
  android:layout_width="match_parent"
  android:layout_height="180dp"
  app:rollviewpager_play_delay="3000"/>
</RelativeLayout>

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.