android - how to reduce spacing in the bitmap (render the text) -


i code print text in form of image. problem is,when print.the spacing far each line. dont know how. in code not have "\n" . dont why become that. whether drawtext or drawbackground

public void drawtext(string text, int textsize) {       textpaint textpaint = new textpaint(paint.anti_alias_flag | paint.linear_text_flag); //(paint.anti_alias_flag | paint.linear_text_flag)     textpaint.setstyle(paint.style.fill);     textpaint.setcolor(color.black);     textpaint.settextsize(textsize);      try     {         typeface tf =typeface.createfromasset(getassets(),"fonts/andalemono.ttf");         textpaint.settypeface(tf);     }     catch(exception e)     {         log.d("your tag", "typeface error: ", e);     }      staticlayout mtextlayout = new staticlayout(text, textpaint, 370, layout.alignment.align_normal, 1.0f, 0.0f, false);     //draw background     paint paint = new paint(paint.anti_alias_flag | paint.linear_text_flag);     paint.setstyle(paint.style.fill);     paint.setcolor(color.white);     float baseline = (int) (-paint.ascent() + 0.5f);      int height = (int) ((baseline + paint.descent()+ 0.5f + (textsize/2)));      bitmap image = bitmap.createbitmap(370, height, bitmap.config.argb_8888);     canvas c = new canvas(image);     c.drawtext(text,0, baseline, paint);     c.drawpaint(paint);       // draw text     c.save();     c.translate(0,0);     mtextlayout.draw(c);     c.restore();     printbitmap(image); } 

myfunction printbitmap()

public void printbitmap(bitmap bmp) {     if (!myprinter.printimage(bmp))         return;  } 


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -