FileDocCategorySizeDatePackage
TextViewWithCircularIndicator.javaAPI DocAndroid 5.1 API3519Thu Mar 12 22:22:10 GMT 2015android.widget

TextViewWithCircularIndicator

public class TextViewWithCircularIndicator extends TextView

Fields Summary
private static final int
SELECTED_CIRCLE_ALPHA
private final android.graphics.Paint
mCirclePaint
private final String
mItemIsSelectedText
private int
mCircleColor
private boolean
mDrawIndicator
Constructors Summary
public TextViewWithCircularIndicator(android.content.Context context)


       
        this(context, null);
    
public TextViewWithCircularIndicator(android.content.Context context, android.util.AttributeSet attrs)

        this(context, attrs, 0);
    
public TextViewWithCircularIndicator(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr)

        this(context, attrs, defStyleAttr, 0);
    
public TextViewWithCircularIndicator(android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr, int defStyleRes)

        super(context, attrs);


        // Use Theme attributes if possible
        final TypedArray a = mContext.obtainStyledAttributes(attrs,
                R.styleable.DatePicker, defStyleAttr, defStyleRes);
        final int resId = a.getResourceId(R.styleable.DatePicker_yearListItemTextAppearance, -1);
        if (resId != -1) {
            setTextAppearance(context, resId);
        }

        final Resources res = context.getResources();
        mItemIsSelectedText = res.getString(R.string.item_is_selected);

        a.recycle();

        init();
    
Methods Summary
public java.lang.CharSequencegetContentDescription()

        CharSequence itemText = getText();
        if (mDrawIndicator) {
            return String.format(mItemIsSelectedText, itemText);
        } else {
            return itemText;
        }
    
private voidinit()

        mCirclePaint.setTypeface(Typeface.create(mCirclePaint.getTypeface(), Typeface.BOLD));
        mCirclePaint.setAntiAlias(true);
        mCirclePaint.setTextAlign(Paint.Align.CENTER);
        mCirclePaint.setStyle(Paint.Style.FILL);
    
public voidonDraw(android.graphics.Canvas canvas)

        super.onDraw(canvas);
        if (mDrawIndicator) {
            final int width = getWidth();
            final int height = getHeight();
            int radius = Math.min(width, height) / 2;
            canvas.drawCircle(width / 2, height / 2, radius, mCirclePaint);
        }
    
public voidsetCircleColor(int color)

        if (color != mCircleColor) {
            mCircleColor = color;
            mCirclePaint.setColor(mCircleColor);
            mCirclePaint.setAlpha(SELECTED_CIRCLE_ALPHA);
            requestLayout();
        }
    
public voidsetDrawIndicator(boolean drawIndicator)

        mDrawIndicator = drawIndicator;