title: Draw Text inside an Arc using canvas
body: <p>I am working in an android application to draw a circle and divide them equally and bind text inside the divided portion in the circle(like pichart). I have drawn a circle and divided them equally, but I want to bind text inside the divided portion. Please look into my code and give a solution. Thanks in advance.</p>
  
  <p><img src="https://i.stack.imgur.com/5vnq8.png" alt="enter image description here"></p>
  
  <pre><code>public class MainActivity extends Activity {
      /** Called when the activity is first created. */
      float values[] = { 130, 130, 130, 130, 130 };
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          LinearLayout linear = (LinearLayout) findViewById(R.id.linearlay);
          values = calculateData(values);
          linear.addView(new MyGraphview(this, values));
      }
  
      private float[] calculateData(float[] data) {
  
          float total = 0;
          for (int i = 0; i &lt; data.length; i++) {
              total += data[i];
          }
          for (int i = 0; i &lt; data.length; i++) {
              data[i] = 360 * (data[i] / total);
          }
          return data;
  
      }
  
      public class MyGraphview extends View {
  
          private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);     
          private float[] value_degree;
          private int[] COLORS = { Color.YELLOW, Color.GREEN, Color.WHITE,
                  Color.CYAN, Color.RED };
          RectF rectf = new RectF(10, 10, 300, 300);
          Rect rect = new Rect(10, 10, 300, 300);
          int temp = 0;
          String rotatedtext;
          Path path;
  
          public MyGraphview(Context context, float[] values) {
              super(context);
              path = new Path();
              value_degree = new float[values.length];
              for (int i = 0; i &lt; values.length; i++) {
                  value_degree[i] = values[i];
              }
  
              paint.setTextSize(16);
              rotatedtext = "Rotated  :)";
          }
  
          @Override
          protected void onDraw(Canvas canvas) {
              super.onDraw(canvas);
  
              for (int i = 0; i &lt; value_degree.length; i++) {
                  if (i == 0) {
  
                      paint.setColor(COLORS[i]);
                      canvas.drawArc(rectf, 0, value_degree[i], true, paint);
  
                  } else {
  
                      temp += (int) value_degree[i - 1];
                      paint.setColor(COLORS[i]);
                      canvas.drawArc(rectf, temp, value_degree[i], true, paint); //
  
                  }
              }
  
          }
  
      }
  }
  </code></pre>