Search code examples
javaandroidmobile-application

is there way to create white dot using code that shows progress of onboarding?


As you can see in this link(http://amyjokim.com/wp-content/uploads/2014/05/Duolingo-Onboarding-3.jpg)

AT the bottom of picture, There are dots to show the progress of onboarding. is there way to create white dot using code that shows progress of onboarding? What is the best way to create them? using image?

is there way to create white dot using code that shows progress of onboarding?


Solution

  • those are called ViewPagerIndicator.

    This library provide options for a lot of shapes and sizes in viewpager indicator with sample application.

    Include one of the widgets in your view. This should usually be placed adjacent to the ViewPager it represents.

    <com.viewpagerindicator.TitlePageIndicator
        android:id="@+id/titles"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent" />
    

    In your onCreate method (or onCreateView for a fragment), bind the indicator to the ViewPager.

    //Set the pager with an adapter
     ViewPager pager = (ViewPager)findViewById(R.id.pager);
     pager.setAdapter(new TestAdapter(getSupportFragmentManager()));
    
     //Bind the title indicator to the adapter
     TitlePageIndicator titleIndicator = (TitlePageIndicator)findViewById(R.id.titles);
     titleIndicator.setViewPager(pager);
    

    (Optional) If you use an OnPageChangeListener with your view pager you should set it in the indicator rather than on the pager directly.

     //continued from above
     titleIndicator.setOnPageChangeListener(mPageChangeListener);