Custom Tab Indicator(With Arrow down like Indicator)

前端 未结 3 1041
青春惊慌失措
青春惊慌失措 2020-12-09 10:26

Is there a wat to make a indicator like this?
it has some pointed arrow down like in the selected item?

3条回答
  •  我在风中等你
    2020-12-09 10:51

    Here is the code for anyone requiring an upward triangle using @Konstantin Loginov code

    private Path getTrianglePath(int arrowSize) {
    
            mSelectedIndicatorPaint.setStyle(Paint.Style.FILL_AND_STROKE);
            mSelectedIndicatorPaint.setAntiAlias(true);
            mSelectedIndicatorPaint.setColor(Color.WHITE);
    
            int leftPointX = mIndicatorLeft + (mIndicatorRight - mIndicatorLeft) / 2 - arrowSize * 1 / 2;
            int mTopX = leftPointX + arrowSize;
            int mTopY = getHeight() - arrowSize;
            int rightPointX = leftPointX + arrowSize * 2;
    
            int leftPointY = getHeight();
    
            Point left = new Point(leftPointX, leftPointY);
            Point right = new Point(rightPointX, leftPointY);
            Point bottom = new Point(mTopX, mTopY);
    
            Path path = new Path();
            path.setFillType(Path.FillType.EVEN_ODD);
            path.setLastPoint(left.x, left.y);
            path.lineTo(right.x, right.y);
            path.lineTo(bottom.x, bottom.y);
            path.lineTo(left.x, left.y);
            path.close();
    
            return path;
        }
    

提交回复
热议问题