1

I am developing application having a resemblance appearance like " Gallery application". When I click on image from the gallery... I want to fit image to whole screen.. I used this code..but it does not work . can you guide me for this ... Here is code for the same:

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

  imgView.setMinimumWidth(width);
  imgView.setMinimumHeight(height);

  imgView.setMaxWidth(width);
  imgView.setMaxHeight(height);
Cœur
  • 37,241
  • 25
  • 195
  • 267
NovusMobile
  • 1,813
  • 2
  • 21
  • 48

2 Answers2

0

you should use the following attribute of the imageview to fit the image to the screen.

Controls how the image should be resized or moved to match the size of this ImageView.

Must be one of the following constant values.

Constant Value

matrix 0

fitXY 1

fitStart 2

fitCenter 3

fitEnd 4

center 5

centerCrop 6

centerInside 7

android:scaleType="fitxy"

like wise you can use others to change the size of your image.

SilentKiller
  • 6,944
  • 6
  • 40
  • 75
  • 2
    you need to tell him *which* attribute (**cough** `scaleType` **cough**) – Fuzzical Logic Jan 17 '12 at 09:33
  • 1
    `android:scaleType="fitxy"` like wise you can use others to change the size of your image. – SilentKiller Jan 17 '12 at 09:35
  • 2
    I'm just saying your **answer** doesn't mention `scaleType` at all. You should edit it so he knows. :) He also seems to be trying it programmatically. You might include the code variant too, but that's not necessary for your answer to be correct. – Fuzzical Logic Jan 17 '12 at 09:36
0

You may consider having the image open in its own activity, with android:noHistory="true" in the manifest, and onClick() have it end the activity. That way you don't have to worry about the image resizing and ruining everything in the activity it is being chosen in.

AJcodez
  • 31,780
  • 20
  • 84
  • 118