Question

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);
Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top