按钮周围的圆形文字

时间:2015-06-13 09:47:02

标签: android

我有一个环形按钮,我想在按钮周围添加一个文字。具体来说,我想要的文字如下。 enter image description here

1 个答案:

答案 0 :(得分:1)

这是一个简单的自定义视图,允许您以循环方式绘制文本。

SELECT CASE WHEN MAX(col) = MIN(col) THEN MAX(col) ELSE 'both' END
FROM   my_table

示例:

public class GraphicsView extends View {
         private static final String QUOTE = "This is a 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);} 
                                            } }