TextViewWithCircularIndicatorpublic class TextViewWithCircularIndicator extends android.widget.TextView A text view which, when pressed or activated, displays a blue circle around the text. |
Fields Summary |
---|
private static final int | SELECTED_CIRCLE_ALPHA | android.graphics.Paint | mCirclePaint | private final int | mRadius | private final int | mCircleColor | private final String | mItemIsSelectedText | private boolean | mDrawCircle |
Constructors Summary |
---|
public TextViewWithCircularIndicator(android.content.Context context, android.util.AttributeSet attrs)
super(context, attrs);
Resources res = context.getResources();
mCircleColor = res.getColor(R.color.blue);
mRadius = res.getDimensionPixelOffset(R.dimen.month_select_circle_radius);
mItemIsSelectedText = context.getResources().getString(R.string.item_is_selected);
init();
|
Methods Summary |
---|
public void | drawIndicator(boolean drawCircle)
mDrawCircle = drawCircle;
| public java.lang.CharSequence | getContentDescription()
CharSequence itemText = getText();
if (mDrawCircle) {
return String.format(mItemIsSelectedText, itemText);
} else {
return itemText;
}
| private void | init()
mCirclePaint.setFakeBoldText(true);
mCirclePaint.setAntiAlias(true);
mCirclePaint.setColor(mCircleColor);
mCirclePaint.setTextAlign(Align.CENTER);
mCirclePaint.setStyle(Style.FILL);
mCirclePaint.setAlpha(SELECTED_CIRCLE_ALPHA);
| public void | onDraw(android.graphics.Canvas canvas)
super.onDraw(canvas);
if (mDrawCircle) {
final int width = getWidth();
final int height = getHeight();
int radius = Math.min(width, height) / 2;
canvas.drawCircle(width / 2, height / 2, radius, mCirclePaint);
}
|
|