开发者

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 = (GestureOverlay开发者_如何学运维View)findViewById(R.id.gestures);
    v.removeAllViews();
    v.addView(image, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

Thanks to help me...


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜