Hitendra
Hitendra

Reputation: 3226

android:overlap images?

This is the snapshot from the app "Google Catalogs".I just want to know that how we can do this kind of image overlapping.![enter image description here][1]

Upvotes: 1

Views: 1500

Answers (3)

Hitendra
Hitendra

Reputation: 3226

Here is the code that i want.

public Bitmap convertImage(Bitmap bitmap, int param1, int param2, int degree) {
        float f1 = 1.0F;
        int i = bitmap.getWidth();
        int j = bitmap.getHeight();

        if (((Math.abs(i - param1) <= 1) || (param1 <= 0))
                && (Math.abs(j - param2) <= 1) || (param2 <= 0) && degree == 0)
            return bitmap;

        Matrix matrix = new Matrix();
        float f4 = 1.0F;
        if (param1 > 0) {
            float f2 = param1;
            float f3 = i;
            f4 = f2 / f3;
        } else if (param2 > 0) {
            float f5 = param2;
            float f6 = j;
            f1 = f5 / f6;
        }

        boolean b1 = matrix.postScale(f4, f1);
        float f7 = degree;
        boolean b2 = matrix.postRotate(f7);
        Bitmap localbitmap = bitmap;

        int k = 0;

        bitmap = Bitmap.createBitmap(localbitmap, 0, k, i, j, matrix, true);
        return bitmap;

    }

Usage:-

BitmapDrawable drawable = (BitmapDrawable) getResources().getDrawable(
                R.drawable.ic_launcher);
        Bitmap localBitmap2 = convertImage(drawable.getBitmap(), -1, -1,
                -7);

        imageview1.setImageBitmap(localBitmap2);

Upvotes: 2

RobGThai
RobGThai

Reputation: 5969

You can use FrameLayout to stack images on top of each other. However, I doubt they do it that way as you are going to have indefinite number of images in the same screen. This will result in memory problem sooner or later.

What I think they do is taking some sample from that catalog then draw the image into canvas then render it as one entity. They might be using just one canvas for the whole panel then control it that way as well.

Just my two cents. Trying to think of the possibilities for you here.

Upvotes: 3

Narc&#237;s Calvet
Narc&#237;s Calvet

Reputation: 7452

You can use images into ImageView objects in a FrameLayout to overlap images. Here I posted an example.

Upvotes: 1

Related Questions