Scale ImageView to fit without stretching - android

How can i fit the ImageView without stretching? I've already tried all 'scaleType' but no one works. this image is from instagram API.
When i use 'Matrix' scaleType.

Depends which side you want to fit.
You can resize bitmap if you need some custom fit.
You can use 'scaleType' centerCrop to fill all ImageView.
P.S. but if you want to make rectangle picture from square one, without losing some part of picture - you have no chance, it is impossible anyway.
Maybe it is better for you to resize ImageView to fit image ratio.

Related

ImageView bitmap is stretched after activity transition

Is there any specific reason why this is happening?
This is the image after the transition happens.
You haven't provided any code to help us diagnose your problem, but your terrifying image (that looks like Jim Carrey) may be related to the tileMode. Your image looks like it's exhibiting clamping.
Clamping is when the edge color is replicated if the bitmap for an ImageView is smaller in size than the ImageView. These are all the options, along with a suitable picture of Jim:
disabled - Do not tile the bitmap. This is the default value.
clamp - Replicates the edge color.
repeat - Repeats the bitmap in both direction.
mirror - Repeats the shader's image horizontally and vertically, alternating mirror images so that adjacent images always seam.
Since it looks like your Bitmap is smaller than your ImageView and I don't think you actually want to use any tile mode (just use the default of disabled), I'd recommend either:
A) Use ImageView's setScaleType() so that the Bitmap resizes to fill the ImageView, using the centerCrop value (though check this blog for more examples), or...
B) Make your Bitmap larger
(I'd recommend A)

set image from Gallery or Camera to fit to Imageview android

I set image From Gallery and Camera to Imageview.I used Touchimageview for pinch Zoom Functionality for imageview.
Here is Link For this Touchimageview : https://github.com/MikeOrtiz/TouchImageView/blob/master/src/com/ortiz/touch/TouchImageView.java
But image is not set ProPerly in Imageview.
In the Picture,
The left side is What Actually happen with me.
The Right side which i wanted Fit to imgeview same as Imageview height.
I Used ScaleType = "CenterCrop" But After That i Cant able to Zoom in Out in Imageview.
1).How to Crop Bitmap Like Fit to imageview with keep aspect resio?
2).or How to set Image From gallery or camera to Fit To imageview And Add Zoom in out Functionality?
Help me to Solve This issue
Thanks You in Advance
For zoom-able ImageView user Gesture ImageView Library
You can download library from here, it's easy to use. this library provides you zoomable ImageView so use Gesture ImageView instead of Simple ImageView
https://github.com/jasonpolites/gesture-imageview
use android:scaleType="fitxy". Make sure your image is of higher resolution, otherwise the image will lose its quality. It may also look stretched if it the image doesn't maintain aspect ratio

Is there any way to make an image to be exact aspect ratio in a button in android?

I can't use scale-type because it's not an imageview.

Resize an image to square resolution

I am developing an android application which resizes android pictures. I was wondering if its possible to resize a file with resolution (1080X1920) to (500X500) square size.
Without looking too bad (quality and dimensions).
Let me show you an example.
First image:
Resized picture:
Answers using code will be appreciated
If you don't want to distort the image you have two options:
Crop the image
Implement the seam carving algorithm
Edit: this assumes you want to fill up the whole square. If not, just keep the width/height ratio and downscale the image properly so that the largest dimension fits in the side of the square.

difference between setting imageView smaller vs scaling image itself

I guess this question could be applied to both iphone and and android.
When I want to show smaller image,
I can set imageView to smaller size and let iphone handle the resizing to fit in the view.
Or
I can actually resize the image itself.(using opengl call, or such as wrapper call createScaledBitmap in android)
I find option 1 is faster.
I always wondered why?
I also wondered the memory consumed by the image is governed by the size of imageView or image?
This is good question, I think when we resize the imageView to smaller that And image(UIImage) is greater that time memory consumption is more because of that image (UIImage) size is more respect to display in imageView. I think second option would be good to save memory .
Image resizing need extra CPU cycles.So Its better to manually resize the image.

Categories

Resources