FileDocCategorySizeDatePackage
ActionMenuButton.javaAPI DocAndroid 1.5 API3334Wed May 06 22:42:42 BST 2009com.android.camera

ActionMenuButton

public class ActionMenuButton extends android.widget.TextView
TextView that draws a bubble behind the text. We cannot use a LineBackgroundSpan because we want to make the bubble taller than the text and TextView's clip is too aggressive.

Fields Summary
private static final float
CORNER_RADIUS
private static final float
PADDING_H
private static final float
PADDING_V
private static final int[]
RESTRICTED_STATE_SET
private final android.graphics.RectF
mRect
private android.graphics.Paint
mPaint
private boolean
mRestricted
Constructors Summary
public ActionMenuButton(android.content.Context context)


       
        super(context);
        init();
    
public ActionMenuButton(android.content.Context context, android.util.AttributeSet attrs)

        super(context, attrs);
        init();
    
public ActionMenuButton(android.content.Context context, android.util.AttributeSet attrs, int defStyle)

        super(context, attrs, defStyle);
        init();
    
Methods Summary
public voiddraw(android.graphics.Canvas canvas)

        final Layout layout = getLayout();
        final RectF rect = mRect;
        final int left = getCompoundPaddingLeft();
        final int top = getExtendedPaddingTop();

        rect.set(left + layout.getLineLeft(0) - PADDING_H,
                top + layout.getLineTop(0) - PADDING_V,
                Math.min(left + layout.getLineRight(0) + PADDING_H, mScrollX + mRight - mLeft),
                top + layout.getLineBottom(0) + PADDING_V);
        canvas.drawRoundRect(rect, CORNER_RADIUS, CORNER_RADIUS, mPaint);

        super.draw(canvas);
    
protected voiddrawableStateChanged()

        invalidate();
        super.drawableStateChanged();
    
private voidinit()

        setFocusable(true);

        mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mPaint.setColor(getContext().getResources().getColor(R.color.bubble_dark_background));
    
public booleanisRestricted()

        return mRestricted;
    
protected int[]onCreateDrawableState(int extraSpace)

        int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
        if (isRestricted()) {
            mergeDrawableStates(drawableState, RESTRICTED_STATE_SET);
        }
        return drawableState;
    
public voidsetRestricted(boolean restricted)

        if (restricted != mRestricted) {
            mRestricted = restricted;
            refreshDrawableState();
        }