Picture Carousel is a more of our use of a feature, I have also written a similar article (http://blog.csdn.net/double2hao/article/details/48896297), but to tell the truth that their own writing is not particularly convenient, And often bugs tend to be more numerous. On GitHub, there are some great gods who specifically wrote Viewpager's Carousel framework and open source for everyone's reference, and this blog teaches you how to simply use the open source framework Rollviewpager.
interested in Rollviewpager, or want to learn more in-depth can go directly to GitHub download source learning: Https://github.com/Jude95/RollViewPager
Effect:(source code at the end of the article)
Some of the main features supported:
Supports infinite loops. When touched, pauses playback until the end touches a delay period and resumes playback. It looks just like this. The indicator can also be customized for points that can be numbers, and the position can also be changed.
Main operation Process:
1, set playback interval, transparency, indicators (indicators can be the default origin, numbers, can also customize the picture)
2, set the adapter, this demo is Staticpageradapter, this is relatively simple, with more, there are other needs can see GitHub source code.
The main need to set the picture, the number of pictures and so on.
Mainactivity:
Package Com.example.double2.rollviewpagertest;import Android.graphics.color;import Android.os.bundle;import Android.support.v7.app.appcompatactivity;import Android.view.menu;import Android.view.menuitem;import Android.view.view;import Android.view.viewgroup;import Android.widget.imageview;import Com.jude.rollviewpager.rollpagerview;import Com.jude.rollviewpager.adapter.staticpageradapter;import Com.jude.rollviewpager.hintview.colorpointhintview;public class Mainactivity extends Appcompatactivity {private Rollpagerview Mrollviewpager; @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); Mrollviewpager = (Rollpagerview) Findviewbyid (R.id.roll_view_pager); Set playback interval mrollviewpager.setplaydelay (1000); Set the transparency mrollviewpager.setanimationdurtion (500); Set Adapter Mrollviewpager.setadapter (new Testnormaladapter ()); Set the indicator (sequentially) Customize indicator picture//Set DOT indicator color//Set text indicator//Hide indicator//mrollviewpager.sethintview (new Iconhintview (thi S, R.drawable.point_focus, R.drawable.point_normal)); Mrollviewpager.sethintview (New Colorpointhintview (this, color.yellow,color.white)); Mrollviewpager.sethintview (New Texthintview (this)); Mrollviewpager.sethintview (NULL); } private class Testnormaladapter extends Staticpageradapter {private int[] IMGs = {r.drawable. IMG1, R.drawable.img2, R.DRAWABLE.IMG3, R.drawable.img4,}; @Override public view GetView (ViewGroup container, int position) {ImageView view = new ImageView (contai Ner.getcontext ()); View.setimageresource (Imgs[position]); View.setscaletype (ImageView.ScaleType.CENTER_CROP); View.setlayoutparams (New Viewgroup.layoutparams (ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); return view; } @Override public int getcount () {return imgs.length; } }}
Activity_main:
<?xml version= "1.0" encoding= "Utf-8"? ><relativelayout xmlns:android= "http://schemas.android.com/apk/res/ Android " xmlns:app=" Http://schemas.android.com/apk/res-auto " xmlns:tools=" http://schemas.android.com/ Tools " android:layout_width=" match_parent " android:layout_height=" match_parent " tools:context=". Mainactivity "> <com.jude.rollviewpager.rollpagerview android:id=" @+id/roll_view_pager " Android:layout_width= "Match_parent" android:layout_height= "180DP" app:rollviewpager_play_delay= "3000" /></relativelayout>
Source: http://download.csdn.net/detail/double2hao/9511532
Android Picture Carousel effect, simple use of Rollviewpager