Search code examples
javaandroidimageviewpicassoandroid-image

Overlay images with Picasso


I have one main product image, which always is displayed in my ImageView. Now it is possible that there are several overlays (which have the same size as the original image, but a lot of transparent areas).

All those images come from remote URLs. E.g.:

Main image

Overlay

Is it possible to load all of them into one ImageView?


Solution

  • You can have your custom ImageView, load bitmaps with Picasso and then draw those bitmaps on canvas:

    @Override
    protected void onDraw(final Canvas canvas) {
        super.onDraw(canvas);
    
        canvas.drawBitmap(bitmap1, 0, 0, null); // lower image
        canvas.drawBitmap(bitmap2, 0, 0, null); // upper image
    }