Skip to content

Commit 422167d

Browse files
author
Edward Dale
committed
Left title overlaps current title with long text during right dragging. Fixes JakeWharton#101
1 parent d94643b commit 422167d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

library/src/com/viewpagerindicator/TitlePageIndicator.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,17 @@ protected void onDraw(Canvas canvas) {
430430
//Fade out/in unselected text as the selected text fades in/out
431431
mPaintText.setAlpha(colorTextAlpha - (int)(colorTextAlpha * selectedPercent));
432432
}
433+
434+
//Except if there's an intersection with the right view
435+
if (i < boundsSize - 1) {
436+
Rect rightBound = bounds.get(i + 1);
437+
//Intersection
438+
if (bound.right + mTitlePadding > rightBound.left) {
439+
int w = bound.right - bound.left;
440+
bound.left = (int) (rightBound.left - w - mTitlePadding);
441+
bound.right = bound.left + w;
442+
}
443+
}
433444
canvas.drawText(pageTitle, 0, pageTitle.length(), bound.left, bound.bottom + mTopPadding, mPaintText);
434445

435446
//If we are within the selected bounds draw the selected text

0 commit comments

Comments
 (0)