Pregunta

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.

¿Fue útil?

Solución

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

Canvas Text Drawing Issues

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top