java - Draw text on Canvas with custom Height - Android -
i'm drawing text on canvas code:
@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); }
here result:
but want text have bigger height, want this:
i don't want change font size, height of text. how can ?
i found solution this:
// closing hardware acceleration setlayertype(layer_type_software, paint); paint.gettextbounds(first, 0, first.length(), bounds); float posx = (canvas.getwidth() - bounds.width()) / 2; // center float posy = ((canvas.getheight() - bounds.height()) / 2); // center canvas.scale(1, 10, posx, posy); canvas.drawtext(first, posx, posy, paint);
Comments
Post a Comment