I want to draw a string say "stackoverflow" in circular view like below image can any one suggest how to do it. And also i need click event on each characer.
Asked
Active
Viewed 8,658 times
10
-
[Take a look at this, it's been asked before](http://stackoverflow.com/a/8343851/420015) – adneal Apr 14 '12 at 03:45
-
it was to draw a circle around text but not to draw text in circular way – Shankar Agarwal Apr 14 '12 at 03:48
-
[Okay, but it has been asked before. This link is right](http://stackoverflow.com/a/8337972/420015) – adneal Apr 14 '12 at 03:52
-
edited my post. how to click event – Shankar Agarwal Apr 14 '12 at 05:02
2 Answers
11
You need to make a customized view for this. in onDraw method, create a path object, add circle to that object, and then use Canvas Object to draw text on that path.
Path path = new Path();
path.addCircle(x, y, radius, Path.Direction.CW);
myCanvas.drawTextOnPath(myText, path, offset, 0, myPaint);
Edit:
use this line of code when using os 4.0 and above:
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
-
-
-
To have Click Event, you have to implement touch listener on the View, you need to set TouchListener on the View, and matches the character's co-ordinates with Touch Events Co-ordinates you can fire Click Event. – jeet Apr 19 '12 at 04:27
-
@AgarwalShankar how did you achieved this, could you please share the relevant code. – Anurag Jan 03 '17 at 10:24