Search code examples
androiduinavigationbarmaterial-designandroid-image

Pocket casts like navigation bar background image


I was wondering how the pocket casts app creates its navigation bar background image. From what I notice they get the images from the podcasts you have subscribed and somehow create this image and set it as the nav bar background. Very cool effect!

Any tips in recreating something similar to this?

Thanks!

Example


Solution

  • Following the steps from @Nikola answer:

        public static Bitmap createBitmap(int width, int height, List<Bitmap> bitmaps) {
        final Bitmap newBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        final Canvas canvas = new Canvas(newBitmap);
    
        final Paint paint = new Paint();
        paint.setAlpha(50);
    
        int currentWidth = 0;
        int currentHeight = 0;
        for (Bitmap scaledBitmap : bitmaps) {
            //draw the bitmap
            canvas.drawBitmap(scaledBitmap, currentWidth, currentHeight, paint);
    
            //update width
            currentWidth += scaledBitmap.getWidth();
            //update height
            if (currentWidth > width) {
                currentWidth = 0;
                currentHeight += scaledBitmap.getHeight();
            }
        }
    
        return newBitmap;
    }
    

    Main difference is that instead of a ColorFilter I ended up setting a transparency (with setAlpha).

    If in the end you still want to rotate, simply call imageView.setRotation(degree) in the imageview that will hold your bitmap.

    Cheers