AndroidTagGroup實作雲标簽效果,各種背景效果的标簽,并且支援添加,
大體實作:有一個TagsManager管理TagGroup,自定義TagGroup,對TagGroup設定setTags(tags);
TagGroup extends ViewGroup,TagGroup 由多個TagView組成,TagView繼承TextView 。
本例子來源:https://github.com/2dxgujun/AndroidTagGroup
主要繪制代碼如下:
@Override
protected void onDraw(Canvas canvas) {
canvas.drawArc(mLeftCornerRectF, -180, 90, true, mBackgroundPaint);
canvas.drawArc(mLeftCornerRectF, -270, 90, true, mBackgroundPaint);
canvas.drawArc(mRightCornerRectF, -90, 90, true, mBackgroundPaint);
canvas.drawArc(mRightCornerRectF, 0, 90, true, mBackgroundPaint);
canvas.drawRect(mHorizontalBlankFillRectF, mBackgroundPaint);
canvas.drawRect(mVerticalBlankFillRectF, mBackgroundPaint);
if (isChecked) {
canvas.save();
canvas.rotate(45, mCheckedMarkerBound.centerX(), mCheckedMarkerBound.centerY());
canvas.drawLine(mCheckedMarkerBound.left, mCheckedMarkerBound.centerY(),
mCheckedMarkerBound.right, mCheckedMarkerBound.centerY(), mCheckedMarkerPaint);
canvas.drawLine(mCheckedMarkerBound.centerX(), mCheckedMarkerBound.top,
mCheckedMarkerBound.centerX(), mCheckedMarkerBound.bottom, mCheckedMarkerPaint);
canvas.restore();
}
canvas.drawPath(mBorderPath, mBorderPaint);
super.onDraw(canvas);
}