BulletSpanpublic class BulletSpan extends Object implements LeadingMarginSpan, android.text.ParcelableSpan
Fields Summary |
---|
private final int | mGapWidth | private final boolean | mWantColor | private final int | mColor | private static final int | BULLET_RADIUS | private static android.graphics.Path | sBulletPath | public static final int | STANDARD_GAP_WIDTH |
Constructors Summary |
---|
public BulletSpan()
mGapWidth = STANDARD_GAP_WIDTH;
mWantColor = false;
mColor = 0;
| public BulletSpan(int gapWidth)
mGapWidth = gapWidth;
mWantColor = false;
mColor = 0;
| public BulletSpan(int gapWidth, int color)
mGapWidth = gapWidth;
mWantColor = true;
mColor = color;
| public BulletSpan(android.os.Parcel src)
mGapWidth = src.readInt();
mWantColor = src.readInt() != 0;
mColor = src.readInt();
|
Methods Summary |
---|
public int | describeContents()
return 0;
| public void | drawLeadingMargin(android.graphics.Canvas c, android.graphics.Paint p, int x, int dir, int top, int baseline, int bottom, java.lang.CharSequence text, int start, int end, boolean first, android.text.Layout l)
if (((Spanned) text).getSpanStart(this) == start) {
Paint.Style style = p.getStyle();
int oldcolor = 0;
if (mWantColor) {
oldcolor = p.getColor();
p.setColor(mColor);
}
p.setStyle(Paint.Style.FILL);
if (c.isHardwareAccelerated()) {
if (sBulletPath == null) {
sBulletPath = new Path();
// Bullet is slightly better to avoid aliasing artifacts on mdpi devices.
sBulletPath.addCircle(0.0f, 0.0f, 1.2f * BULLET_RADIUS, Direction.CW);
}
c.save();
c.translate(x + dir * BULLET_RADIUS, (top + bottom) / 2.0f);
c.drawPath(sBulletPath, p);
c.restore();
} else {
c.drawCircle(x + dir * BULLET_RADIUS, (top + bottom) / 2.0f, BULLET_RADIUS, p);
}
if (mWantColor) {
p.setColor(oldcolor);
}
p.setStyle(style);
}
| public int | getLeadingMargin(boolean first)
return 2 * BULLET_RADIUS + mGapWidth;
| public int | getSpanTypeId()
return TextUtils.BULLET_SPAN;
| public void | writeToParcel(android.os.Parcel dest, int flags)
dest.writeInt(mGapWidth);
dest.writeInt(mWantColor ? 1 : 0);
dest.writeInt(mColor);
|
|