Do not use Canvas size.

fork-5.53.8
Alan Evans 2019-07-17 14:07:20 -04:00 zatwierdzone przez GitHub
rodzic c902d17f98
commit c7bfede74c
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 4 dodań i 1 usunięć

Wyświetl plik

@ -11,4 +11,6 @@
<issue id="ExtraTranslation" severity="warning" />
<issue id="ImpliedQuantity" severity="warning" />
<issue id="CanvasSize" severity="error" />
</lint>

Wyświetl plik

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