improved original status span padding, fixed #170
This commit is contained in:
parent
ee646b2c05
commit
a65de0cdbc
|
@ -48,13 +48,13 @@ public class OriginalStatusSpan extends ReplacementSpan {
|
||||||
final float density = context.getResources().getDisplayMetrics().density;
|
final float density = context.getResources().getDisplayMetrics().density;
|
||||||
mCornerRadius = density * 2;
|
mCornerRadius = density * 2;
|
||||||
mPaint.setStrokeWidth(density);
|
mPaint.setStrokeWidth(density);
|
||||||
mPadding = (int) (density * 2);
|
mPadding = (int) (density * 4);
|
||||||
ThemeUtils.getDarkLightForegroundColors(context, mDarkLightColors);
|
ThemeUtils.getDarkLightForegroundColors(context, mDarkLightColors);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSize(final Paint paint, final CharSequence text, final int start, final int end, final Paint.FontMetricsInt fm) {
|
public int getSize(final Paint paint, final CharSequence text, final int start, final int end, final Paint.FontMetricsInt fm) {
|
||||||
// paint.setTextSize(paint.getTextSize() * 0.8f);
|
paint.setTextSize(paint.getTextSize() * 0.8f);
|
||||||
return (int) paint.measureText(text, start, end) + mPadding * 2;
|
return (int) paint.measureText(text, start, end) + mPadding * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +78,6 @@ public class OriginalStatusSpan extends ReplacementSpan {
|
||||||
mBounds.inset(mPaint.getStrokeWidth() / 2, mPaint.getStrokeWidth() / 2);
|
mBounds.inset(mPaint.getStrokeWidth() / 2, mPaint.getStrokeWidth() / 2);
|
||||||
canvas.drawRoundRect(mBounds, mCornerRadius, mCornerRadius, mPaint);
|
canvas.drawRoundRect(mBounds, mCornerRadius, mCornerRadius, mPaint);
|
||||||
paint.setColor(innerTextColor);
|
paint.setColor(innerTextColor);
|
||||||
canvas.drawText(text, start, end, x + mPadding, y, paint);
|
canvas.drawText(text, start, end, x + mPadding, top + (bottom - top) / 2 - (paint.descent() + paint.ascent()) / 2, paint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue