Fix OrderedListItemSpan text position (baseline)
This commit is contained in:
parent
7c7b1f59a8
commit
4a16e67ea1
@ -6,7 +6,8 @@ import android.support.annotation.NonNull;
|
||||
abstract class CanvasUtils {
|
||||
|
||||
static float textCenterY(int top, int bottom, @NonNull Paint paint) {
|
||||
return (int) (bottom - ((bottom - top) / 2) - ((paint.descent() + paint.ascent()) / 2.F + .5F));
|
||||
// @since 1.1.1 it's `top +` and not `bottom -`
|
||||
return (int) (top + ((bottom - top) / 2) - ((paint.descent() + paint.ascent()) / 2.F + .5F));
|
||||
}
|
||||
|
||||
private CanvasUtils() {
|
||||
|
@ -59,8 +59,7 @@ public class OrderedListItemSpan implements LeadingMarginSpan {
|
||||
left = x + (width * dir) + (width - numberWidth);
|
||||
}
|
||||
|
||||
final float numberY = CanvasUtils.textCenterY(top, bottom, p);
|
||||
|
||||
c.drawText(number, left, numberY, p);
|
||||
// @since 1.1.1 we are using `baseline` argument to position text
|
||||
c.drawText(number, left, baseline, p);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user