3

次のコードを使用して、キャンバスにテキストを描画しています。

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

結果は次のとおりです。

初め

しかし、テキストの高さを大きくしたいので、次のようなものが必要です:

2番

フォント サイズは変更したくありません。このテキストの高さだけを変更します。これどうやってするの ?

4

1 に答える 1