Skip to content Skip to sidebar Skip to footer

Increase The Size Of Image In Android App

I have attached a image in my android app but when i launch the app it is very small.Please suggest how to increase its size in app so that its clearly visible. Below is the snippe

Solution 1:

Change your scaleType to centerCrop and it will be worked. Here is full guide about ScaleType in ImageView in Android. The following is a list of all the most common types of scaleType:

center : Displays the image centered in the view with no scaling.

centerCrop : Scales the image such that both the x and y dimensions are greater than or equal to the view, while maintaining the image aspect ratio; centers the image in the view.

centerInside Scales the image to fit inside the view, while maintaining the image aspect ratio. If the image is already smaller than the view, then this is the same as center.

fitCenter Scales the image to fit inside the view, while maintaining the image aspect ratio. At least one axis will exactly match the view, and the result is centered inside the view.

fitStart Same as fitCenter but aligned to the top left of the view.

fitEnd Same as fitCenter but aligned to the bottom right of the view.

fitXY Scales the x and y dimensions to exactly match the view size; does not maintain the image aspect ratio.

matrix Scales the image using a supplied Matrix class. The matrix can be supplied using the setImageMatrix method. A Matrix class can be used to apply transformations such as rotations to an image.

Solution 2:

In the imageView you have set dimensions as 200dp x 200dp for the imageView.

  • Set a background color for the imageView eg yellow. This will let you know the amount of area the imageView covers. In case if the imageView doesn't cover the area desirable to you, increase the height and width of the imageView.
  • In case if the imageView covers enough space but the image is still small and covers only a portion of the yellow area (bg of imageView). Then you can use scaleType = fitxy in imageView, if you dont want to maintain aspect ratio else go for scaleType = centerCrop or centerInside

Post a Comment for "Increase The Size Of Image In Android App"