当前位置: 动力学知识库 > 问答 > 编程问答 >

android - Canvas.drawText leading to overlapping of text

问题描述:

I am trying draw different text at the same position .I am creating the typeface and paint object in the following code and drawing the text.It works fine till here.It draws the text with the typeface which i have specified.But when i drawtext another time at the same position it overlaps the earlier text .

 mFace = Typeface.createFromAsset(getContext().getAssets(),"digital.ttf");

text_paint= new Paint();

text_paint.setColor(Color.BLUE);

text_paint.setStyle(Paint.Style.FILL);

text_paint.setTypeface(mFace);

text_paint.setTextSize((float) (height*0.05076));

text_paint.setAntiAlias(true);

canvas.drawText("ABC",(float)(width*0.5) ,(float)(height*0.55), text_paint);

canvas.drawText("PQRSTUV",(float)(width*0.5) ,(float)(height*0.55), text_paint);

Any idea how to remove the earlier text and add the new text at the same position.

网友答案:

Check the below link for the detailed explanations for your problem :

Canvas Text Drawing Issues

分享给朋友:
您可能感兴趣的文章:
随机阅读: