Skip to content

Commit

Permalink
use float while calculating positionfor indicator so no pixels get lost
Browse files Browse the repository at this point in the history
  • Loading branch information
astuetz committed May 1, 2013
1 parent e9da1b2 commit 8c1dc48
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,18 +302,18 @@ protected void onDraw(Canvas canvas) {

// default: line below current tab
View currentTab = tabsContainer.getChildAt(currentPosition);
int lineLeft = currentTab.getLeft();
int lineRight = currentTab.getRight();
float lineLeft = currentTab.getLeft();
float lineRight = currentTab.getRight();

// if there is an offset, start interpolating left and right coordinates between current and next tab
if (currentPositionOffset > 0f && currentPosition < tabCount - 1) {

View nextTab = tabsContainer.getChildAt(currentPosition + 1);
int nextTabLeft = nextTab.getLeft();
int nextTabRight = nextTab.getRight();
final float nextTabLeft = nextTab.getLeft();
final float nextTabRight = nextTab.getRight();

lineLeft = (int) (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
lineRight = (int) (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
lineLeft = (currentPositionOffset * nextTabLeft + (1f - currentPositionOffset) * lineLeft);
lineRight = (currentPositionOffset * nextTabRight + (1f - currentPositionOffset) * lineRight);
}

canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint);
Expand Down

0 comments on commit 8c1dc48

Please sign in to comment.