Skip to content

Commit 63fee36

Browse files
committed
Merge pull request JakeWharton#112 from scompt/overlapping_left_title
Left title overlaps current title with long text during right dragging
2 parents 11c0f9e + 422167d commit 63fee36

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
@@ -428,6 +428,17 @@ protected void onDraw(Canvas canvas) {
428428
//Fade out/in unselected text as the selected text fades in/out
429429
mPaintText.setAlpha(colorTextAlpha - (int)(colorTextAlpha * selectedPercent));
430430
}
431+
432+
//Except if there's an intersection with the right view
433+
if (i < boundsSize - 1) {
434+
Rect rightBound = bounds.get(i + 1);
435+
//Intersection
436+
if (bound.right + mTitlePadding > rightBound.left) {
437+
int w = bound.right - bound.left;
438+
bound.left = (int) (rightBound.left - w - mTitlePadding);
439+
bound.right = bound.left + w;
440+
}
441+
}
431442
canvas.drawText(pageTitle, 0, pageTitle.length(), bound.left, bound.bottom + mTopPadding, mPaintText);
432443

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

0 commit comments

Comments
 (0)