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:

first

but want text have bigger height, want this:

second

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

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -