ActionMenuButtonpublic 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 |
Methods Summary |
---|
public void | draw(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 void | drawableStateChanged()
invalidate();
super.drawableStateChanged();
| private void | init()
setFocusable(true);
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mPaint.setColor(getContext().getResources().getColor(R.color.bubble_dark_background));
| public boolean | isRestricted()
return mRestricted;
| protected int[] | onCreateDrawableState(int extraSpace)
int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
if (isRestricted()) {
mergeDrawableStates(drawableState, RESTRICTED_STATE_SET);
}
return drawableState;
| public void | setRestricted(boolean restricted)
if (restricted != mRestricted) {
mRestricted = restricted;
refreshDrawableState();
}
|
|