title: How to convert the text to bitmap in Android
body: <p>please help me to draw a text with rounded rectangle as background. I have to draw many texts on a canvas and the text has rounded background. SO what I am trying is to write a function "createTextBitmap" which return a bitmap image so that we can draw image(which return by the function) on a main canvas.
  the 'createTextBitmap'function can return a created bitmap, the bitmap image is the one,which contains the text with rounded edge background...</p>
  
  <p>i have tried one, which gives below.</p>
  
  <pre><code> private Bitmap ProcessingBitmap(String text,Paint paint, boolean lastPoint){
      Bitmap bm1 = null;
      Bitmap newBitmap = null;
  
      Rect bounds = new Rect();
      paint.getTextBounds(text, 0, text.length(), bounds);
      float width = bounds.width();
      float height =bounds.height();
      float radius;
      if (width &gt; height){
          radius = height/4;
      }else{
          radius = width/4;
      }
      Paint paint1 = new Paint();
      paint1.setColor(Color.GREEN);
      paint1.setStrokeWidth(5);   
      paint1.setStyle(Paint.Style.FILL);
      float center_x, center_y;
      center_x = width/4;
      center_y = height/4;
      final RectF rect = new RectF();
      rect.set(center_x - radius, 
              center_y - radius, 
              center_x + radius, 
              center_y + radius);
      Canvas canvas2 = new Canvas();
      canvas2.drawRoundRect(rect, 0, 0, paint);
      canvas2.drawText(text, 0, 0, paint);
      return newBitmap;
       }
  </code></pre>
  
  <p>and my question is How can we convert this canvas2 to a bitmap image? and image has the size  of text bounds,
    which look like<img src="https://i.stack.imgur.com/nPh7D.png" alt="a sample which i need"></p>