Tuesday, 15 June 2010

android - Add a TextView inside a Custom View that herited View -


I would like to know whether it is possible to add a text visual program to a custom view, which looks heats in this customview, I I draw some figures with canvas and I have to put some text too. I tried to use the draw text but it does not provide enough possibilities, especially for the state of the text, I want to write the text inside, and properly in the middle of a circle and at the same time my text is in the circle Fits well (I already know how to do this)

This is the reason why I am thinking that it is possible to add a text view by declaring it and attracting it. Maybe I need to use the infix?

I do not really know what the best options are, so I need your help :)

You can use draft text (string text, float x, float y, paint paint) method for this. Like this:

paint mPaint = new paint ();

mPaint.setColor (Color.BLACK);

mPaint.setAntiAlias ​​(true);

mPaint.setStyle (Paint.Style.FILL);

canvas.drawText ("Your Text Here", 10, 20, mPaint);

No comments:

Post a Comment