title: How to add background text to Pie chart in android?
body: <p>I have created a pie chart using the following code in android fragment, This program created a pie graph with predefined ratio of circle and padding between the slices, i wanted to add text as the below mentioned image, Here is the code i have tried : </p>
  
  <pre><code>public class PieFragment extends Fragment {
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
  
      final View v = inflater.inflate(R.layout.fragment_piegraph, container, false);
      final Resources resources = getResources();
      final PieGraph pg = (PieGraph) v.findViewById(R.id.piegraph);
      final Button animateButton = (Button) v.findViewById(R.id.animatePieButton);
  
      PieSlice slice = new PieSlice();
      slice.setColor(resources.getColor(R.color.green_light));
      slice.setSelectedColor(resources.getColor(R.color.transparent_orange));
      slice.setValue(2);
      slice.setTitle("first");
      pg.addSlice(slice);
  
      slice = new PieSlice();
      slice.setColor(resources.getColor(R.color.orange));
      slice.setValue(3);
      pg.addSlice(slice);
  
    /*  slice = new PieSlice();
      slice.setColor(resources.getColor(R.color.purple));
      slice.setValue(8);
      pg.addSlice(slice);*/
      pg.setOnSliceClickedListener(new OnSliceClickedListener() {
  
          @Override
          public void onClick(int index) {
              Toast.makeText(getActivity(),
                      "Slice " + index + " clicked",
                      Toast.LENGTH_SHORT)
                      .show();
          }
      });
  
      Bitmap b = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
      pg.setBackgroundBitmap(b);
  
      SeekBar seekBar = (SeekBar) v.findViewById(R.id.seekBarRatio);
      seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
          @Override
          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
              pg.setInnerCircleRatio(progress);
          }
  
          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {
  
          }
  
          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {
  
          }
      });
  
      seekBar = (SeekBar) v.findViewById(R.id.seekBarPadding);
      seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
          @Override
          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
              pg.setPadding(progress);
          }
  
          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {
  
          }
  
          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {
  
          }
      });
  
      if (android.os.Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB_MR1)
      animateButton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              for (PieSlice s : pg.getSlices())
                  s.setGoalValue((float)Math.random() * 10);
              pg.setDuration(1000);//default if unspecified is 300 ms
              pg.setInterpolator(new AccelerateDecelerateInterpolator());//default if unspecified is linear; constant speed
              pg.setAnimationListener(getAnimationListener());
              pg.animateToGoalValues();//animation will always overwrite. Pass true to call the onAnimationCancel Listener with onAnimationEnd
  
          }
      });
      return v;
  }
  
  @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
  public Animator.AnimatorListener getAnimationListener(){
      if (android.os.Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB_MR1)
      return new Animator.AnimatorListener() {
          @Override
          public void onAnimationStart(Animator animation) {
  
          }
  
          @Override
          public void onAnimationEnd(Animator animation) {
              Log.d("piefrag", "anim end");
          }
  
          @Override
          public void onAnimationCancel(Animator animation) {//you might want to call slice.setvalue(slice.getGoalValue)
              Log.d("piefrag", "anim cancel");
          }
  
          @Override
          public void onAnimationRepeat(Animator animation) {
  
          }
      };
      else return null;
  
  }}
  </code></pre>
  
  <p>When i run this it looks as follows </p>
  
  <p><img src="https://i.stack.imgur.com/Kr3G0.png" alt="result"></p>
  
  <p>and xml is as follows </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;    &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical"&gt;
  &lt;com.echo.holographlibrary.PieGraph
      android:layout_width="match_parent"
      android:layout_height="0dip"
      android:layout_weight="1"
      android:layout_margin="@dimen/default_margin"
      android:id="@+id/piegraph"
      app:pieInnerCircleRatio="195"
      app:pieSlicePadding="0dip"/&gt;
  &lt;LinearLayout
      android:orientation="horizontal"
      android:layout_margin="@dimen/default_margin"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"&gt;
      &lt;TextView
          android:layout_width="0dip"
          android:layout_height="match_parent"
          android:gravity="center_vertical"
          android:text="Inner Circle Ratio"
          android:layout_weight="1"/&gt;
      &lt;SeekBar
          android:layout_width="0dip"
          android:layout_height="wrap_content"
          android:progress="128"
          android:max="240"
          android:id="@+id/seekBarRatio"
          android:layout_weight="1"/&gt;
  &lt;/LinearLayout&gt;
  &lt;LinearLayout
      android:orientation="horizontal"
      android:layout_margin="@dimen/default_margin"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"&gt;
      &lt;TextView
          android:layout_width="0dip"
          android:layout_height="match_parent"
          android:gravity="center_vertical"
          android:text="Padding"
          android:layout_weight="1"/&gt;
      &lt;SeekBar
      android:layout_width="0dip"
      android:layout_height="wrap_content"
      android:progress="0"
      android:max="10"
      android:id="@+id/seekBarPadding"
      android:layout_weight="1"/&gt;
  &lt;/LinearLayout&gt;
  &lt;Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Animate to random values"
      android:id="@+id/animatePieButton"
      android:layout_weight="0"/&gt;    &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>How to add text to this pie chart as in the below image </p>
  
  <p><img src="https://i.stack.imgur.com/w0xmw.png" alt="chart image"></p>
  
  <p>I have tried adding text view's near by the pie graph but it is not showing.Needed Solution</p>