private void calculateDotPositions(int width, int height) {
        if (!measured)
            return;

        int left = getPaddingLeft();
        int top = getPaddingTop();
        int right = width - getPaddingRight();
        int bottom = height - getPaddingBottom();
        float middle = top + bottom / 2f;
        float center = left + right / 2f;

        int requiredWidth = getRequiredWidth();
        float startLeft = center - requiredWidth / 2f + dotRadius;

        dotCenterX = new float[Math.max(1, pageCount)];
        for (int i = 0; i < pageCount; i++) {
            dotCenterX[i] = startLeft + i * (dotDiameter + gap);
        }

        dotTopY = middle - dotRadius;
        dotCenterY = middle;
        dotBottomY = middle + dotRadius;

        setCurrentPageImmediate();
    }
An ink inspired widget for indicating pages in a {@link ViewPager}.
library/src/main/java/com/heinrichreimersoftware/materialintro/view/InkPageIndicator.java