Fix OrderedListItemSpan text position (baseline)

This commit is contained in:
Dimitry Ivanov 2018-08-06 16:14:37 +03:00
parent 7c7b1f59a8
commit 4a16e67ea1
2 changed files with 4 additions and 4 deletions

View File

@ -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() {

View File

@ -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);
}
}