次のコードを使用して、キャンバスにテキストを描画しています。
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawColor(Color.WHITE);
Paint paint = new Paint();
Rect bounds = new Rect();
paint.setColor(Color.BLACK);
paint.setTextSize(50);
paint.getTextBounds(first, 0, first.length(), bounds);
canvas.drawText(first, (canvas.getWidth() - bounds.width()) / 2, 50, paint);
}
結果は次のとおりです。
しかし、テキストの高さを大きくしたいので、次のようなものが必要です:
フォント サイズは変更したくありません。このテキストの高さだけを変更します。これどうやってするの ?