clement
clement

Reputation: 4266

Resize a bitmap as big that the screen can in Android

I'm using methods to edit the dimensions of a picture but I can't size it to take the entiere screen... I already try to put "FILL_PARENT" as an argument but it doesn't work!

Here's my code fragment that's working :

ImageView image; 
Bitmap bitmap;
...
image.setImageBitmap(Bitmap.createScaledBitmap(bitmap, 300, 300, false));

I already found a solution but we have to use Canvas and I feel that there is a simplest way! (for information : "The canvas way" )

I have a problem with the gestures too. To be able to capt gestures, I have to "play" with views :

GestureOverlayView v = (GestureOverlayView)findViewById(R.id.gestures);
    v.removeAllViews();
    v.addView(image, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

Thanks to help me...

Upvotes: 0

Views: 362

Answers (1)

Andro Selva
Andro Selva

Reputation: 54330

Use the below code to get the width and height of your device.

    Display display = getWindowManager().getDefaultDisplay();
        int width = display.getWidth();
        int height = display.getHeight();

And now set the bitmap width and height based on the value returned by the above methods.

Upvotes: 1

Related Questions