Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to add CirclePageIndicator with ViewPager in android

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 6.14k
    Comment on it

    CircularPagerIndicator is usually a kind of indicator that used to know how many images or tabs are left in our view. It is like a dot at the bottom of a view, more you can get by implementing below few lines in your project.

    Step1: permission needed to add indicator

    compile 'com.mcxiaoke.viewpagerindicator:library:2.4.1'

    Step2: Use a layout file having viewPager and CirclePageIndicator

    <android.support.v4.view.ViewPager
                android:id="@+id/pager"
                android:layout_width="match_parent"
                android:layout_height="@dimen/one_eighty_dp">
    
            </android.support.v4.view.ViewPager>
    
            <com.viewpagerindicator.CirclePageIndicator
                android:id="@+id/indicator"
                android:layout_width="match_parent"
                android:layout_height="25dp"
                android:layout_marginTop="-30dp"
                android:padding="@dimen/ten_dp"
                app:fillColor="#88FF0000"
                app:pageColor="@android:color/white"
                app:radius="@dimen/five_dp"
                app:strokeWidth="2dp" />

    Step3: Now getting CircularPageIndicator id and attaching it to the pager.

    ViewPager pager = (ViewPager) view.findViewById(R.id.pager);
    	pager.setAdapter((new ImageSlideAdapter(imageList, context));
    
            CirclePageIndicator circlePageIndicator = (CirclePageIndicator) view.findViewById(R.id.indicator);
            circlePageIndicator.setViewPager(pager);

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: