SoFunction
Updated on 2025-04-07

Android RollPagerView implements carousel diagram

Android RollPagerView implements carousel diagram

Android picture carousel effect, simple use of RollViewPager

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

Loading packages in (app)

compile ':rollviewpager:1.2.9'  

Implementation code:

//Advertising carouselmViewPager = (RollPagerView) ();     
(new ImageLoopAdapter(getActivity(), mViewPager)); 

// 

public class ImageLoopAdapter extends LoopPagerAdapter { 
 
  String[] imgs = new String[0]; 
  private Context mContext; 
  public ImageLoopAdapter(Context mContext,RollPagerView viewPager) { 
    super(viewPager); 
 
     = mContext; 
  } 
 
  @Override 
  public View getView(ViewGroup container, int position) { 
    ImageView view = new ImageView(()); 
    (.CENTER_CROP); 
    (new (.MATCH_PARENT, .MATCH_PARENT)); 
    (mContext).load([position]).into(view); 
 
    return view; 
  } 
 
  @Override 
  public int getRealCount() { 
    return ; 
  } 
} 

Add image data source:

You can set it yourself here

public class  Constants { 
 
  public static String[] URL = { 
      "/connett/c3115411-3669-466d-8ef2-e6c42c690303", 
      "http://7xjww9.com1./Hopetoun_falls.jpg", 
      "/crm_test_1449051526097.jpg", 
  }; 
 
 
} 

The above is an example of Android's carousel image implementation. If you have any questions, please leave a message or go to the community of this site to communicate and discuss. Thank you for reading. I hope it can help you. Thank you for your support for this site!