android - Circular text around a button -
this question has answer here:
i have button in ring shape , want add text around button. specifically, want text below.
this simple custom view allows draw text in circular way.
public class graphicsview extends view { private static final string quote = "this curved text"; private path circle; private paint cpaint; private paint tpaint; public graphicsview(context context) { super(context); int color = color.argb(127, 255, 0, 255); circle = new path(); circle.addcircle(230, 350, 150, direction.cw); cpaint = new paint(paint.anti_alias_flag); cpaint.setstyle(paint.style.stroke); cpaint.setcolor(color.ltgray); cpaint.setstrokewidth(3); setbackgroundresource(r.drawable.heart); tpaint = new paint(paint.anti_alias_flag); tpaint.setstyle(paint.style.fill_and_stroke); tpaint.setcolor(color.black); tpaint.settextsize(50);} @override protected void ondraw(canvas canvas) { canvas.drawtextonpath(quote, circle, 485, 20, tpaint);} } }
example :
public class mainactivity extends activity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(new graphicsview(this));} }
Comments
Post a Comment