Put signature in a layout?
<p>I am working on a signature project..What i want to do is take a signature from a user and then put it in a view that contains his name, address and phone number and at the bottom i have to add the signature...So i have done the signature part by using a bitmap and canvas..Now what i want to do is add it to this view and save it together as a image file...
So shall i create a layout and put the signature in it or shall i make another bitmap and put integrate the name,add,no and signature...???.This is what i have done so far..It works fine and perfectly saves a signature...Question is how and what shall i do next???</p>

<pre><code>enter code here

/**
 * Constructor used for initializing variable
 * @param c
 *          = Context of the application
 * @param attrs
 *          = AttributeSet of XML tags for signatureView
 */
public Signature(Context c,AttributeSet attrs)
{

    super(c,attrs);
    ctx=c;
    initialize();

  //  tv1.setText((CharSequence) tv);

}

private void initialize()
{
    mBitmap = Bitmap.createBitmap(BITMAP_WIDTH,BITMAP_HEIGHT, Bitmap.Config.ARGB_8888);// i have used 480X800 resolution
    mCanvas = new Canvas(mBitmap);
    mPath = new Path();
    mBitmapPaint = new Paint(Paint.DITHER_FLAG);
    mPaint = new Paint();
    setpaint(Color.BLACK);
    mPaint.setColor(Color.BLACK);
    mPaint.setShadowLayer(10,color.darker_gray, 20, 20);
    mPaint.setTextSize(15);
    mPaint.setFlags(Paint.ANTI_ALIAS_FLAG);             
    mCanvas.drawBitmap(mBitmap, 0, 0, null);
}


/**
 * This method sets the required parameters for paint object to be used.
 * This method also sets drawing cache for SignatureView.
 * This method is private for class and only called by constructor.
 * @param color
 *          = It takes the Color as an argument in integer form which is
 *            used while drawing.
 */
private void setpaint(int color)
{
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
    mPaint.setColor(color);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStrokeWidth(2);
    mPaint.setAlpha(255);
    mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));
    this.setDrawingCacheEnabled(true);
    this.setDrawingCacheBackgroundColor(Color.TRANSPARENT);
    this.setDrawingCacheQuality(DRAWING_CACHE_QUALITY_HIGH);
}

/**
 * This method clears canvas by reinitializing bitmap and canvas.
 */
public void clearCanvas()
{
    //mBitmap = Bitmap.createBitmap(BITMAP_WIDTH,BITMAP_HEIGHT, Bitmap.Config.ARGB_8888);
    //mCanvas=new Canvas(mBitmap);
    initialize();
    invalidate();
}

/**
 * This method enables saving drawing made on SignatureView.
 * @param file
 *          = This method takes a file object as parameter which is initialized 
 *            with the path and filename to be saved.
 * @return
 *      = It returns a boolean value whether file is saved successfully or not.
 */
public boolean sign(File file)
{   
    sign=this.getDrawingCache();
            ImageView iv = (ImageView) findViewById(R.id.Ivsignature);      
    try{
    iv.setImageBitmap(sign);
    }catch(Exception e)
    {

    }

    String filename = file.getAbsolutePath ();
    FileOutputStream fos = null;
    try {
        fos = new FileOutputStream (file);
        sign.compress (CompressFormat.JPEG, 100, fos);
//      Toast.makeText(ctx, filename+"  saved", Toast.LENGTH_LONG).show();
        return true;
    } catch (Throwable ex) {
        Toast.makeText(ctx, "error: "+ex.getMessage(), Toast.LENGTH_LONG).show();
        return false;
    }

}

/* (non-Javadoc)
 * @see android.view.View#onSizeChanged(int, int, int, int)
 */
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) 
{
    super.onSizeChanged(w, h, oldw, oldh);
}

/* (non-Javadoc)
 * @see android.view.View#onDraw(android.graphics.Canvas)
 */
@Override
protected void onDraw(Canvas canvas) 
{
    canvas.drawColor(Color.TRANSPARENT);
    canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);
    canvas.drawPath(mPath, mPaint);
}

/**
 * This method is called in onTouchEvent on ACTION_DOWN event
 * this method resets path to draw on canvas and reinitializes 
 * with new coordinates. 
 * @param x
 *      =  x coordinate of ACTION_DOWN event
 * @param y
 *      = y coordinate of ACTION_DOWN event
 */
private void touch_start(float x, float y) 
{
    mPath.reset();
    mPath.moveTo(x, y);
    mX = x;
    mY = y;
}

/**
 * This method is called in onTouchEvent on ACTION_MOVE event
 * this method adds coordinates to path for drawing on canvas. 
 * @param x
 *      = x coordinate of while ACTION_MOVE event
 * @param y
 *      = y coordinate of while ACTION_MOVE event
 */
private void touch_move(float x, float y) 
{
    float dx = Math.abs(x - mX);
    float dy = Math.abs(y - mY);
    if (dx &gt;= TOUCH_TOLERANCE || dy &gt;= TOUCH_TOLERANCE) {
        mPath.quadTo(mX, mY, (x + mX)/2, (y + mY)/2);
        mX = x;
        mY = y;
    }
}

/**
 * This method is called in onTouchEvent on ACTION_UP event
 * this method draws path on canvas and resets path. 
 */
private void touch_up() 
{
    mPath.lineTo(mX, mY);
    mCanvas.drawPath(mPath, mPaint);
    mPath.reset();
}


/* (non-Javadoc)
 * @see android.view.View#onTouchEvent(android.view.MotionEvent)
 */
@Override
public boolean onTouchEvent(MotionEvent event) 
{
    float x = event.getX();
    float y = event.getY();
    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            touch_start(x, y);
            mCanvas.drawPoint(x, y, mPaint);
            invalidate();
            break;
        case MotionEvent.ACTION_MOVE:
            touch_move(x, y);
            invalidate();
            break;
        case MotionEvent.ACTION_UP:
            touch_up();
            invalidate();
            break;
    }

    return true;
}
</code></pre>

<p>}</p>
