Example usage for android.graphics Canvas drawLine

List of usage examples for android.graphics Canvas drawLine

Introduction

In this page you can find the example usage for android.graphics Canvas drawLine.

Prototype

public void drawLine(float startX, float startY, float stopX, float stopY, @NonNull Paint paint) 

Source Link

Document

Draw a line segment with the specified start and stop x,y coordinates, using the specified paint.

Usage

From source file:de.tum.in.tumcampus.auxiliary.calendar.DayView.java

private void drawScrollLine(Rect r, Canvas canvas, Paint p) {
    final int right = computeDayLeftPosition(mNumDays);
    final int y = mFirstCell - 1;

    p.setAntiAlias(false);/*w  w w. j av a  2s .c o  m*/
    p.setStyle(Style.FILL);

    p.setColor(mCalendarGridLineInnerHorizontalColor);
    p.setStrokeWidth(GRID_LINE_INNER_WIDTH);
    canvas.drawLine(GRID_LINE_LEFT_MARGIN, y, right, y, p);
    p.setAntiAlias(true);
}

From source file:android.support.v7.widget.GridLayout.java

private void drawLine(Canvas graphics, int x1, int y1, int x2, int y2, Paint paint) {
    if (isLayoutRtlCompat()) {
        int width = getWidth();
        graphics.drawLine(width - x1, y1, width - x2, y2, paint);
    } else {/*from  w w  w. ja  va 2 s . c  o  m*/
        graphics.drawLine(x1, y1, x2, y2, paint);
    }
}

From source file:com.ring.widget.PagerSlidingTabStrip.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    if (disableViewPager)
        return;//from w  w w.  j av  a2 s .c o m

    /* ? */
    ViewGroup tabsLayout = getTabsLayout();
    int tabCount = tabsLayout.getChildCount();
    if (tabsLayout == null || tabCount == 0) {
        return;
    }

    View currentTab = tabsLayout.getChildAt(currentPosition);
    if (currentTab == null) {
        return;
    }
    int height = getHeight();
    float slidingBlockLeft = currentTab.getLeft();
    float slidingBlockRight = currentTab.getRight();
    if (currentPositionOffset > 0f && currentPosition < tabsLayout.getChildCount() - 1) {
        View nextTab = tabsLayout.getChildAt(currentPosition + 1);
        if (nextTab != null) {
            final float nextTabLeft = nextTab.getLeft();
            final float nextTabRight = nextTab.getRight();
            slidingBlockLeft = (currentPositionOffset * nextTabLeft
                    + (1f - currentPositionOffset) * slidingBlockLeft);
            slidingBlockRight = (currentPositionOffset * nextTabRight
                    + (1f - currentPositionOffset) * slidingBlockRight);
        }
    }
    if (slidingBlockDrawable != null) {
        // ?
        if (disableTensileSlidingBlock) {
            int center = (int) (slidingBlockLeft + (slidingBlockRight - slidingBlockLeft) / 2);
            slidingBlockLeft = center - slidingBlockDrawable.getIntrinsicWidth() / 2;
            slidingBlockRight = center + slidingBlockDrawable.getIntrinsicWidth() / 2;
        }

        slidingBlockDrawable.setBounds((int) slidingBlockLeft,
                getHeight() - slidingBlockDrawable.getIntrinsicHeight(), (int) slidingBlockRight, getHeight());
        slidingBlockDrawable.draw(canvas);
    } else {

        rectPaint.setColor(barColor);

        canvas.drawRect(slidingBlockLeft, height - barHeight, slidingBlockRight, height, rectPaint);
        rectPaint.setColor(underlineColor);
        canvas.drawRect(0, height - underLineHeight, tabsLayout.getWidth(), height, rectPaint);

    }
    if (isAllowDivider) {
        // draw divider

        dividerPaint.setColor(dividerColor);
        for (int i = 0; i < tabCount - 1; i++) {
            View tab = tabsLayout.getChildAt(i);
            canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding,
                    dividerPaint);
        }
    }
}

From source file:com.example.SmartBoard.DrawingView.java

public void onDrawLine(Canvas canvas) {
    Paint paint = drawPaint;/*  ww  w . j av a 2s.c o  m*/
    if (points[1] == null) //point4 null when user did not touch and move on screen.
        return;

    //draw stroke
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(5);

    if (finished) {

        JSONObject objectProperties = new JSONObject();
        String key = UUID.randomUUID().toString();

        try {
            objectProperties.put("id", key);
            objectProperties.put("clientId", client.getClientId());
            objectProperties.put("type", "Line");
            objectProperties.put("color", drawPaint.getColor());
            objectProperties.put("size", 5);
            objectProperties.put("startx", linePath.startx());
            objectProperties.put("starty", linePath.starty());
            objectProperties.put("stopx", linePath.stopx());
            objectProperties.put("stopy", linePath.stopy());
            objectProperties.put("gradient", linePath.getGradient());
            objectProperties.put("length", linePath.length());

        } catch (JSONException e) {
            e.printStackTrace();
        }

        objectDrawables.put(key, objectProperties);

        mqtt.publishLine(objectProperties);

        //reset to start drawing again
        points = new Point[4];
        colorballs.clear();
        return;

    }

    canvas.drawLine(linePath.startx(), linePath.starty(), linePath.stopx(), linePath.stopy(), paint);

    // draw the balls on the canvas
    paint.setTextSize(18);
    paint.setStrokeWidth(0);
    for (int i = 0; i < colorballs.size(); i++) {
        ColorBall ball = colorballs.get(i);
        canvas.drawBitmap(ball.getBitmap(), ball.getX(), ball.getY(), paint);
        canvas.drawText("" + (i + 1), ball.getX(), ball.getY(), paint);
    }
}

From source file:com.tbse.mywearapplication.WatchFaceDrawer.java

void onDraw(Context context, IWatchFaceConfig config, Canvas canvas, Rect bounds) {
    final Calendar calendar = config.getCalendar();
    final boolean isAmbient = config.isAmbient();
    final boolean isRound = config.isRound();
    final boolean useLightTheme = !isAmbient && config.isLightTheme();

    mBackgroundPaint.setColor(ContextCompat.getColor(context,
            useLightTheme ? R.color.watchface_background_light : R.color.watchface_background));

    /////////////////////////////////////////////////////////////////////
    // Draw your watch face here, using the provided canvas and bounds //
    /////////////////////////////////////////////////////////////////////

    final int width = bounds.width();
    final int height = bounds.height();

    // Find the center. Ignore the window insets so that, on round
    // watches with a "chin", the watch face is centered on the entire
    // screen, not just the usable portion.
    final float centerX = width / 2f;
    final float centerY = height / 2f;

    // Draw the background.
    if (mIsMobilePreview) {
        if (isRound) {
            canvas.drawCircle(centerX, centerY, centerX, mPreviewBorderPaint);
        } else {/*  w w  w.j a  v  a 2  s.  c  o  m*/
            final float radius = mPreviewSquareRadius;
            final RectF rectF = new RectF(0, 0, canvas.getWidth(), canvas.getHeight());
            canvas.drawRoundRect(rectF, radius, radius, mPreviewBorderPaint);
        }

        final float translateXY = width * 0.05f;
        canvas.translate(translateXY, translateXY);
        canvas.scale(0.9f, 0.9f);

        if (isRound) {
            canvas.drawCircle(centerX, centerY, centerX, mBackgroundPaint);
        } else {
            canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), mBackgroundPaint);
        }
    } else {
        canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), mBackgroundPaint);
    }

    // Draw weather icon
    if (image != null) {
        Matrix matrix = new Matrix();
        matrix.setTranslate(50, 90);
        matrix.preScale(0.2f, 0.2f);
        canvas.drawBitmap(image, matrix, null);
    }

    final float secRot = calendar.get(Calendar.SECOND) / 30f * (float) Math.PI;
    final int minutes = calendar.get(Calendar.MINUTE);
    final float minRot = minutes / 30f * (float) Math.PI;
    final float hrRot = ((calendar.get(Calendar.HOUR) + (minutes / 60f)) / 6f) * (float) Math.PI;

    final float secLength = centerX - mSecondOuterOffset;
    final float minLength = centerX - mMinuteOuterOffset;
    final float hrLength = centerX - mHourOuterOffset;

    if (!isAmbient) {
        final float secX = (float) Math.sin(secRot) * secLength;
        final float secY = (float) -Math.cos(secRot) * secLength;
        canvas.drawLine(centerX, centerY, centerX + secX, centerY + secY, mSecondHandPaint);
    }

    final float minX = (float) Math.sin(minRot) * minLength;
    final float minY = (float) -Math.cos(minRot) * minLength;
    canvas.drawLine(centerX, centerY, centerX + minX, centerY + minY, mMinuteHandPaint);

    final float hrX = (float) Math.sin(hrRot) * hrLength;
    final float hrY = (float) -Math.cos(hrRot) * hrLength;
    canvas.drawLine(centerX, centerY, centerX + hrX, centerY + hrY, mHourHandPaint);

    // Draw weather text
    canvas.drawText(day, 50, 50, isAmbient ? ambientTextPaint : textPaint);
    canvas.drawText(low, 50, 65, isAmbient ? ambientTextPaint : textPaint);
    canvas.drawText(high, 80, 65, isAmbient ? ambientTextPaint : textPaint);
    canvas.drawText(weatherDescription, 50, 80, isAmbient ? ambientTextPaint : textPaint);

}

From source file:com.zxly.o2o.view.MPagerSlidingTab.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (isInEditMode() || tabCount == 0 || !isNeedToDoDraw) {
        return;/*from  w w  w  . ja v a 2 s .  c  om*/
    }

    final int height = getHeight();

    // draw underline
    //        rectPaint.setColor(underlineColor);
    //        canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint);

    // draw indicator line
    rectPaint.setColor(indicatorColor);

    // default: line below current tab
    View currentTab = tabsContainer.getChildAt(currentPosition);
    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);
        final float nextTabLeft = nextTab.getLeft();
        final float nextTabRight = nextTab.getRight();

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

    //
    // canvas.drawRect(0,height - indicatorHeight/2, Config.displayMetrics.widthPixels, height, botLine);

    canvas.drawRect(lineLeft
            - (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, AppController.displayMetrics),
            height - indicatorHeight, lineRight + (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
                    2, AppController.displayMetrics),
            height, rectPaint);

    //        draw divider
    //
    //        Log.d("getInfo", " left :" + (lineLeft - (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, AppController.displayMetrics))
    //                + "   top :" + (height - indicatorHeight)
    //                + "  right :" + (lineRight + (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, AppController.displayMetrics))
    //                +"  bot:"+height);

    //     Log.d("getInfo", " left :"+getLeft() +"   right :"+getRight() + "  x :"+getX()  +"  y:"+getY());
    dividerPaint.setColor(dividerColor);
    for (int i = 0; i < tabCount - 1; i++) {
        View tab = tabsContainer.getChildAt(i);
        canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint);
    }

}

From source file:com.cssweb.android.view.KlineMini.java

public void onDraw(Canvas canvas) {
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(1);//from  w  ww. j  a v  a 2s  .com

    tPaint = new Paint();
    tPaint.setStyle(Paint.Style.STROKE);
    tPaint.setTypeface(Typeface.DEFAULT_BOLD);
    tPaint.setAntiAlias(true);
    tPaint.setTextSize(dTextSize);
    //
    tips = (int) tPaint.measureText("0");

    try {
        if (actualDataLen == 0) {
            return;
        }
        if (zs)
            axisLabelWidth = (int) Math.max(tPaint.measureText("99999.99"), tPaint.measureText("11000"));
        else
            axisLabelWidth = (int) tPaint.measureText("11000");
        klineWidth = width - axisLabelWidth;
        //?spaceWidth???
        visualKLineCount = (int) ((klineWidth - spaceWidth) / (spaceWidth + shapeWidth));

        if (isSingleMoved == false && isTrackStatus == false) {
            if (actualDataLen > visualKLineCount) {
                actualPos = actualDataLen - visualKLineCount;
                count = visualKLineCount;
            } else {
                actualPos = 0;
                count = actualDataLen;
            }
        }

        calcMaxMin(actualPos);

        if (!isTrackStatus) {
            moveQuote(actualDataLen - 1);
        } else {
            if (trackLineV == 0) {
                trackLineV = (int) (visualPos * (spaceWidth + shapeWidth) - shapeWidth / 2);
                isTrackNumber = actualPos + visualPos - 1;
            }
            if (isTrackNumber < 0) {
                isTrackNumber = 0;
            } else if (isTrackNumber > actualDataLen - 1) {
                isTrackNumber = actualDataLen - 1;
            }
            paint.setColor(GlobalColor.clrGrayLine);
            canvas.drawLine(klineX + trackLineV, axisLabelHeight, klineX + trackLineV, height - axisLabelHeight,
                    paint);
            moveQuote(isTrackNumber);
            drawQuoteWin(canvas, quoteData, isTrackNumber);
        }

        //
        axisLabelHeight = Font.getFontHeight(dTextSize);
        klineX = axisLabelWidth;
        klineY = axisLabelHeight;

        klineHeight = height - axisLabelHeight * 2;
        axisX = klineX;

        //
        tPaint.setTextAlign(Paint.Align.LEFT);
        tPaint.setColor(GlobalColor.colorM5);
        canvas.drawText(lblIndicatorName, (float) (klineX + shapeWidth), axisLabelHeight - 5, tPaint);

        float size = tPaint.measureText(lblIndicatorName) + tips;
        tPaint.setColor(GlobalColor.colorM10);
        canvas.drawText(lblIndicatorT1, (float) (klineX + shapeWidth + size), axisLabelHeight - 5, tPaint);

        size += tPaint.measureText(lblIndicatorT1) + tips;
        if (size <= (klineWidth - tPaint.measureText(lblIndicatorT2))) {
            //tPaint.setColor(GlobalColor.colorM20);
            tPaint.setARGB(255, 255, 0, 255);
            canvas.drawText(lblIndicatorT2, (float) (klineX + shapeWidth + size), axisLabelHeight - 5, tPaint);
        }

        size += tPaint.measureText(lblIndicatorT2) + tips;
        if (size <= (klineWidth - tPaint.measureText(lblIndicatorT3))) {
            tPaint.setColor(GlobalColor.colorM60);
            canvas.drawText(lblIndicatorT3, (float) (klineX + shapeWidth + size), axisLabelHeight - 5, tPaint);
        }

        //???
        rowHeight = klineHeight / rowNum;
        scale = klineHeight / (highPrice - lowPrice);

        double ratio = (highPrice - lowPrice) / rowNum;
        paint.setColor(GlobalColor.clrLine);
        tPaint.setColor(GlobalColor.colorTicklabel);
        tPaint.setTextAlign(Paint.Align.RIGHT);
        for (int i = 0; i <= rowNum; i++) {
            if (i == rowNum || i == 0) {
                canvas.drawLine(klineX, klineY + rowHeight * i, width, klineY + rowHeight * i, paint);
            } else {
                Graphics.drawDashline(canvas, klineX, klineY + rowHeight * i, width, klineY + rowHeight * i,
                        paint);
            }
            if (i != rowNum && isTrackStatus == false) {
                double AxisLabelPrice = highPrice - ratio * i;
                String AxisLabelPriceText;
                if (zs) {
                    AxisLabelPriceText = Utils.dataFormation(Math.round(AxisLabelPrice), 0);
                } else {
                    AxisLabelPriceText = Utils.dataFormation(AxisLabelPrice, stockdigit);
                }
                canvas.drawText(AxisLabelPriceText, klineX - tips / 4,
                        klineY + rowHeight * i + axisLabelHeight / 2, tPaint);
            }
        }

        //
        if (quoteData != null) {
            //axisX = 0;
            for (int i = actualPos; i < (actualPos + count); i++) {
                if (i == 0)
                    drawKLine(canvas, i - actualPos, quoteData.getJSONArray("K").getJSONArray(i).getDouble(1),
                            quoteData.getJSONArray("K").getJSONArray(i).getDouble(2),
                            quoteData.getJSONArray("K").getJSONArray(i).getDouble(3),
                            quoteData.getJSONArray("K").getJSONArray(i).getDouble(4),
                            quoteData.getJSONArray("K").getJSONArray(i).getDouble(4));
                else
                    drawKLine(canvas, i - actualPos, quoteData.getJSONArray("K").getJSONArray(i).getDouble(1),
                            quoteData.getJSONArray("K").getJSONArray(i).getDouble(2),
                            quoteData.getJSONArray("K").getJSONArray(i).getDouble(3),
                            quoteData.getJSONArray("K").getJSONArray(i).getDouble(4),
                            quoteData.getJSONArray("K").getJSONArray(i - 1).getDouble(4));
            }
            if (mainIndicatorType.toUpperCase().equals("MA"))
                drawMA(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice,
                        highVolume, actualDataLen);

            drawTimeAix(canvas, quoteData, actualPos, count, shapeWidth, spaceWidth, highPrice, lowPrice,
                    highVolume, actualDataLen);
        }

        //?????
        paint.setColor(GlobalColor.clrLine);
        canvas.drawLine(klineX, 0, width, 0, paint);
        canvas.drawLine(klineX, 0, klineX, height - axisLabelHeight, paint);
        canvas.drawLine(width, 0, width, height - axisLabelHeight, paint);
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:net.arvin.afbaselibrary.widgets.PagerSlidingTabStrip.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (isInEditMode() || tabCount == 0) {
        return;/*from  ww  w .j a  v a 2  s  . c  o  m*/
    }

    final int height = getHeight();

    // draw underline
    if (clear) {
        rectPaint.setColor(Color.WHITE);
    } else {
        rectPaint.setColor(underlineColor);
    }

    canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint);

    // draw indicator line
    if (clear) {
        rectPaint.setColor(Color.WHITE);
    } else {
        rectPaint.setColor(indicatorColor);
    }

    // default: line below current tab
    TextView currentTab = (TextView) tabsContainer.getChildAt(currentPosition);

    int textLength = currentTab.getText().length() * ScreenUtil.sp2px(tabTextSize);
    float lineLeft = (currentTab.getRight() - currentTab.getLeft() - textLength) / 2 + ScreenUtil.dp2px(4)
            + currentTab.getLeft();
    float lineRight = lineLeft + textLength - ScreenUtil.dp2px(4) * 2;

    if (tabAddWay == TabAddWay.ITEM_MATCH) {
        lineLeft = currentTab.getLeft();
        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);
        float nextTabLeft = (nextTab.getRight() - nextTab.getLeft() - textLength) / 2 + ScreenUtil.dp2px(4)
                + nextTab.getLeft();
        float nextTabRight = nextTabLeft + textLength - ScreenUtil.dp2px(4) * 2;

        if (tabAddWay == TabAddWay.ITEM_MATCH) {
            nextTabLeft = nextTab.getLeft();
            nextTabRight = nextTab.getRight();
        }

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

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

    // draw divider

    if (clear) {
        dividerPaint.setColor(Color.WHITE);
    } else {
        dividerPaint.setColor(dividerColor);
    }
    if (isDrawDivider) {
        for (int i = 0; i < tabCount - 1; i++) {
            View tab = tabsContainer.getChildAt(i);
            canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding,
                    dividerPaint);
        }
    }
}

From source file:com.zitech.framework.widget.SlidingTabs.java

/**
 * draw the sliding tabs/*from   w w w . ja  v  a 2  s . c  om*/
 *
 * @param canvas canvas
 */
@Override
protected void onDraw(Canvas canvas) {
    // OPPO device may throw nullPointerException here!!!
    try {
        super.onDraw(canvas);
    } catch (NullPointerException e) {
        e.printStackTrace();
    }

    if (isInEditMode() || this.tabCount == 0) {
        return;
    }
    final int height = getHeight();

    // draw underline
    this.rectPaint.setColor(this.underlineColor);
    canvas.drawRect(0, height - this.underlineHeight, tabsContainer.getWidth(), height, rectPaint);

    // draw indicator line
    this.rectPaint.setColor(this.indicatorColor);

    // default: line below current tab
    View currentTab = this.tabsContainer.getChildAt(this.currentPosition);
    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 (this.currentPositionOffset > 0f && this.currentPosition < this.tabCount - 1) {
        View nextTab = this.tabsContainer.getChildAt(this.currentPosition + 1);
        final float nextTabLeft = nextTab.getLeft();
        final float nextTabRight = nextTab.getRight();
        lineLeft = (this.currentPositionOffset * nextTabLeft + (1f - this.currentPositionOffset) * lineLeft);
        lineRight = (this.currentPositionOffset * nextTabRight + (1f - this.currentPositionOffset) * lineRight);
    }
    if (this.indicatorDrawable != null) {
        int indicatorDrawableWidth = this.indicatorDrawable.getIntrinsicWidth();
        this.indicatorDrawable.setBounds((int) (lineLeft + this.tabWidth / 2 - indicatorDrawableWidth / 2),
                height - this.indicatorDrawable.getIntrinsicHeight(),
                (int) (lineRight - tabWidth / 2 + indicatorDrawableWidth / 2), height);
        this.indicatorDrawable.draw(canvas);
    } else {
        canvas.drawRect(lineLeft + this.mMyUnderlinePadding, height - this.indicatorHeight,
                lineRight - this.mMyUnderlinePadding, height, this.rectPaint);
    }

    // draw divider
    this.dividerPaint.setColor(this.dividerColor);
    for (int i = 0; i < this.tabCount - 1; i++) {
        View tab = this.tabsContainer.getChildAt(i);
        canvas.drawLine(tab.getRight(), this.dividerPadding, tab.getRight(), height - this.dividerPadding,
                this.dividerPaint);
    }
}

From source file:com.kindleren.kandouwo.common.views.PagerSlidingTabStrip.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    if (isInEditMode() || tabCount == 0) {
        return;//from  w  ww. j  av a2  s.  c  o  m
    }

    final int height = getHeight();

    // draw indicator line

    rectPaint.setColor(indicatorColor);

    // default: line below current tab
    View currentTab = tabsContainer.getChildAt(currentPosition);
    //change alpha
    if (indicatorDrawable != null) {
        ((TextView) currentTab)
                .setTextColor(tabTextColor.withAlpha((int) (500 * Math.abs(currentPositionOffset - 0.5))));
    }
    currentTab.setSelected(true);
    float lineLeft = currentTab.getLeft();
    float lineRight = currentTab.getRight();
    float lineTop = currentTab.getTop();
    float lineBottom = currentTab.getBottom();

    // 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);
        //change alpha
        if (indicatorDrawable != null) {
            ((TextView) nextTab)
                    .setTextColor(tabTextColor.withAlpha((int) (500 * Math.abs(currentPositionOffset - 0.5))));
        }
        final float nextTabLeft = nextTab.getLeft();
        final float nextTabRight = nextTab.getRight();

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

        //change view state
        if (currentPositionOffset > 0.5) {
            currentTab.setSelected(false);
            nextTab.setSelected(true);
        } else {
            currentTab.setSelected(true);
            nextTab.setSelected(false);
        }
    }
    rectPaint.setColor(underlineColor);
    if (indicatorDrawable != null) {
        indicatorDrawable.setBounds((int) lineLeft + getPaddingLeft(), (int) lineTop + getPaddingTop(),
                (int) lineRight + getPaddingLeft(), (int) lineBottom + getPaddingTop());
        indicatorDrawable.draw(canvas);
    } else {
        canvas.drawRect(lineLeft + 30, height - indicatorHeight, lineRight - 30, height, rectPaint);
    }

    canvas.drawRect(0, height - underlineHeight, tabsContainer.getWidth(), height, rectPaint);

    // draw divider

    dividerPaint.setColor(dividerColor);
    for (int i = 0; i < tabCount - 1; i++) {
        View tab = tabsContainer.getChildAt(i);
        canvas.drawLine(tab.getRight(), dividerPadding, tab.getRight(), height - dividerPadding, dividerPaint);
    }
}