Do not use Canvas size.
This commit is contained in:
parent
c902d17f98
commit
c7bfede74c
2 changed files with 4 additions and 1 deletions
2
lint.xml
2
lint.xml
|
@ -11,4 +11,6 @@
|
|||
<issue id="ExtraTranslation" severity="warning" />
|
||||
<issue id="ImpliedQuantity" severity="warning" />
|
||||
|
||||
<issue id="CanvasSize" severity="error" />
|
||||
|
||||
</lint>
|
||||
|
|
|
@ -47,13 +47,14 @@ public class AsciiEmojiView extends View {
|
|||
float overflow = paint.measureText(emoji) / (getWidth() - getPaddingLeft() - getPaddingRight());
|
||||
if (overflow > 1f) {
|
||||
paint.setTextSize(targetFontSize / overflow);
|
||||
yPos = (int) ((canvas.getHeight() / 2) - ((paint.descent() + paint.ascent()) / 2));
|
||||
yPos = (int) ((getHeight() / 2) - ((paint.descent() + paint.ascent()) / 2));
|
||||
}
|
||||
canvas.drawText(emoji, xPos, yPos, paint);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
//noinspection SuspiciousNameCombination
|
||||
super.onMeasure(widthMeasureSpec, widthMeasureSpec);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue