This should do what you are looking for:
BackgroundBitmap will be your image1 and bitmapToDrawInTheCenter will be your image2 .
public void createImageInImageCenter() { Bitmap backgroundBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); Bitmap bitmapToDrawInTheCenter = BitmapFactory.decodeResource(getResources(), R.drawable.ic_action_search); Bitmap resultBitmap = Bitmap.createBitmap(backgroundBitmap.getWidth(),backgroundBitmap.getHeight(), backgroundBitmap.getConfig()); Canvas canvas = new Canvas(resultBitmap); canvas.drawBitmap(backgroundBitmap, new Matrix(), null); canvas.drawBitmap(bitmapToDrawInTheCenter, (backgroundBitmap.getWidth() - bitmapToDrawInTheCenter.getWidth()) / 2, (backgroundBitmap.getHeight() - bitmapToDrawInTheCenter.getHeight()) / 2, new Paint()); ImageView image = (ImageView)findViewById(R.id.myImage); image.setImageBitmap(resultBitmap); }
source share