Skip to content

Instantly share code, notes, and snippets.

@Gazer
Created September 19, 2016 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gazer/dc1f39f6c5787a0d19240350855b5ca2 to your computer and use it in GitHub Desktop.
Save Gazer/dc1f39f6c5787a0d19240350855b5ca2 to your computer and use it in GitHub Desktop.
public class PagerIndicator extends View {
// Constructors and other methods
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (isInEditMode()) {
drawDots(canvas, 5, 2);
return;
}
if (pager != null) {
int total = pager.getAdapter().getCount();
int currentPage = pager.getCurrentItem();
drawDots(canvas, total, currentPage);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment